Computational Models: Class 6 Benny Chor School of Computer Science Tel Aviv University November 23, 2015 Based on slides by Maurice Herlihy, Brown University, and modifications by Iftach Haitner and Yishay Mansour. Benny Chor (Tel Aviv University) Computational Models, Class 6 November 23, 2015 1 / 75
Backing Up Homework Submissions We had a number of cases where submitted homework assignments were lost. Please scan your hard copy submission and save it. If your submitted assignment disappears, you will be asked to e-mail the scanned copy to the grader. Benny Chor (Tel Aviv University) Computational Models, Class 6 November 23, 2015 2 / 75
And Now for Something Completely Different: A General Model of Computing Tel Aviv shoreline, looking south from the marina towards Jaffa, November 26, 2014. Benny Chor (Tel Aviv University) Computational Models, Class 6 November 23, 2015 3 / 75
Class 6: Outline A General Model of Computing: Turing Machines (TMs) Alternative Models of Computers Multitape TMs, RAMs, Non Deterministic TMs The Church Turing thesis The language classes R = RE core Sipser s book, 3.1, 3.2, & 3.3 Benny Chor (Tel Aviv University) Computational Models, Class 6 November 23, 2015 4 / 75
A Finite Automaton Benny Chor (Tel Aviv University) Computational Models, Class 6 November 23, 2015 5 / 75
A Pushdown Automaton Benny Chor (Tel Aviv University) Computational Models, Class 6 November 23, 2015 6 / 75
A Turing Machine 1 0 1 0 Benny Chor (Tel Aviv University) Computational Models, Class 6 November 23, 2015 7 / 75
Part I Turing Machines (TMs) Benny Chor (Tel Aviv University) Computational Models, Class 6 November 23, 2015 8 / 75
Turing Machines Machines so far (DFA, PDA) read input only once Turing Machines Can back up over the input Can overwrite the input Can write information on tape and come back to it later Benny Chor (Tel Aviv University) Computational Models, Class 6 November 23, 2015 9 / 75
Turing Machines Input string is written on a tape: At each step, machine reads a symbol, and then writes a new symbol, and either moves read/write head to right, or moves read/write head to left Benny Chor (Tel Aviv University) Computational Models, Class 6 November 23, 2015 10 / 75
TM vs. PDA vs. DFA A DFA has no media for writing it must all be in its finite state. A PDA is restricted to reading from the stack in LIFO manner. A Turing machine can both write on the tape and read from it. The TM read-write head can move both to the left and to the right. The TM read-write tape is infinite to the right, but at any given instance, only a finite portion of it is utilized. The special final (accepting/rejecting) states of TM take immediate effect (so the head need not be at some special position, and input need not be exhausted). Benny Chor (Tel Aviv University) Computational Models, Class 6 November 23, 2015 11 / 75
Effects of A Single Step In a single step, the machine changes current state, current head position and tape content at current position. Each step has very local, small effect. But many small effects can accumulate to a meaningful task. Benny Chor (Tel Aviv University) Computational Models, Class 6 November 23, 2015 12 / 75
Example B = {w#w w {0, 1} } Algorithm 1 (A pseudocode" for TM accepting the language B) 1 Check that input contains a single #, If false then reject. 2 Zig-zag across the tape, check identical 0 and identical 1 on two sides of #, and replace them by X. If not identical, reject. 3 When all the letters to the left of the # are marked X, check for remaining letters right of # If there remaining letters are reject, otherwise accept. Benny Chor (Tel Aviv University) Computational Models, Class 6 November 23, 2015 13 / 75
Execution Example for TM on input 0 1 1 0 0 0 # 0 1 1 0 0 0 0 1 1 0 0 0 # 0 1 1 0 0 0 X 1 1 0 0 0 # 0 1 1 0 0 0. X 1 1 0 0 0 # 0 1 1 0 0 0 X 1 1 0 0 0 # X 1 1 0 0 0. X 1 1 0 0 0 # X 1 1 0 0 0 X 1 1 0 0 0 # X 1 1 0 0 0 X X 1 0 0 0 # X 1 1 0 0 0. X X X X X X # X X X X X X = accept Benny Chor (Tel Aviv University) Computational Models, Class 6 November 23, 2015 14 / 75
The Transition Function, δ Let us first understand this function δ : Q Γ Q Γ {L, R}. where δ(q, a) = (p, b, L) means: in state q where head reads tape symbol a, the machine: writes b over a (a = b is possible), moves the head left (this is what the L stands for), enters state p. Benny Chor (Tel Aviv University) Computational Models, Class 6 November 23, 2015 15 / 75
The Transition Function, δ (2) The transition function, now with a move to the right δ(q, a) = (p, b, R) means: in state q where head reads tape symbol a, the machine: writes b over a (a = b is possible), moves the head right (this is what the R stands for), enters state p. Benny Chor (Tel Aviv University) Computational Models, Class 6 November 23, 2015 16 / 75
Turing Machine Formal Definition Definition 2 (Turing machine) A Turing machine (TM) is a 7-tuple (Q, Σ, Γ, δ, q 0, q a, q r ), where Q is a finite set of states, Σ the input alphabet, not containing the blank symbol Γ is the tape alphabet, where Γ and Σ Γ. δ : Q Γ Q Γ {L, R} is the transition function, q 0 Q is the start state, q a Q is the accept state, and q r Q is the reject state. Benny Chor (Tel Aviv University) Computational Models, Class 6 November 23, 2015 17 / 75
Model of Computation Before we start: an input of length n, w = w 1 w 2... w n Σ is placed on n leftmost tape squares, one tape square per input letter. Rest of tape contains blanks since Σ, leftmost blank indicates end of input. read/write head is on leftmost square of tape The computation": M computes" according to transition function δ. Computation continues until q a or q r is reached. Otherwise M runs forever. If M tries to move head beyond left-hand-end of tape, it doesn t move (still M does not crash) Benny Chor (Tel Aviv University) Computational Models, Class 6 November 23, 2015 18 / 75
TM Configurations A TM configuration is a convenient notation for recording the state, head location, and tape contents of a TM in a given instant. Think of it as a snapshot. For example, configuration 1011q 7 0111 means: Current state is q 7, left hand side of tape (to the left of the head) is 1011, right hand side of tape is 0111, and head is on 0 (leftmost entry of right hand side). Benny Chor (Tel Aviv University) Computational Models, Class 6 November 23, 2015 19 / 75
Configurations: The Yield Relation If δ(q i, b) = (q j, c, L), then configuration uaq i bv yields configuration uq j acv. If δ(q i, b) = (q j, c, R), then configuration uaq i bv yields configuration uacq j v. Special case (1): when head is at left end and tries to move left, it changes state and writes on tape but does not move, so if δ(q i, b) = (q j, c, L), configuration q i bv yields q j cv. Special case (2): What happens when head is at right end? We let wq i and wq i denote the same configuration, so moves to the right can now be accomodated. The new configuration is longer as it annexed one blank. This allows configurations to grow in length with computation. Yet at any given moment, they are finitely long. Benny Chor (Tel Aviv University) Computational Models, Class 6 November 23, 2015 20 / 75
Special Configurations Starting configuration: q 0 w Accepting configuration: w 0 q a w 1 Rejecting configuration: w 0 q r w 1 Halting configurations: w 0 q a w 1 and w 0 q r w 1 Benny Chor (Tel Aviv University) Computational Models, Class 6 November 23, 2015 21 / 75
Accepting a Language A Turing machine M accepts an input w, if there is a sequence of configurations C 1, C 2,..., C k such that C 1 is the start configuration of M on w, each C i yields C i+1, C k is an accepting configuration. The collection of strings accepted by M is called the language of M, and is denoted L(M). Benny Chor (Tel Aviv University) Computational Models, Class 6 November 23, 2015 22 / 75
Enumerable Languages, the Class RE Definition 3 A language L is called recursively enumerable if some Turing machine accepts L. (in the textbook, this is called Turing-recognizable) Definition 4 RE is the class of all recursively enumerable languages. Benny Chor (Tel Aviv University) Computational Models, Class 6 November 23, 2015 23 / 75
TM Behavior on an Input On an input, w, a TM may accept reject loop (run forever) Major concern: In general, we never know if the TM will halt. Benny Chor (Tel Aviv University) Computational Models, Class 6 November 23, 2015 24 / 75
Decider TMs Definition 5 A TM M decides a language L, if it accepts it, and M halts on every input in Σ. Namely the TM either reaches state q a (in case w L(M)) or it reaches state q r (in case w / L(M)), but it does not loop. Such TM is called a decider. Benny Chor (Tel Aviv University) Computational Models, Class 6 November 23, 2015 25 / 75
Decidable Languages, the Class R Definition 6 A language L is decidable, if some Turing machine decides it. (in the textbook, this called Turing-decidable, or recursive ) Definition 7 R is the class of all decidable languages. Benny Chor (Tel Aviv University) Computational Models, Class 6 November 23, 2015 26 / 75
A Minor, Technical Point Question 8 To implement algorithms, it is sometimes helpful to tell when a TM is at the left end of the tape. Answer: Mark it with a special symbol. When head reads this symbol, TM knows it is on the leftmost tape square. Benny Chor (Tel Aviv University) Computational Models, Class 6 November 23, 2015 27 / 75
Part II Some Examples Benny Chor (Tel Aviv University) Computational Models, Class 6 November 23, 2015 28 / 75
Example A = {0 2n : n 0} Algorithm 9 (A TM deciding A (pseudocode)) On input w: 1 Move to the right, erasing every other 0 2 Accept if tape contains a single 0. 3 Reject if tape contains an odd number of 0 (greater than one). 4 Return to the start of the tape, and go to Step 1 Benny Chor (Tel Aviv University) Computational Models, Class 6 November 23, 2015 29 / 75
Example A = {0 2n : n 0} TM formal definition Definition 10 (M 2 = (Q, Σ, Γ, δ, q 1, q a, q r )) Q = {q 1, q 2, q 3, q 4, q 5, q a, q r } Σ = {0} input alphabet Γ = {0, x, } tape alphabet q 1 start state q a accept state q r reject state Benny Chor (Tel Aviv University) Computational Models, Class 6 November 23, 2015 30 / 75
Example A = {0 2n : n 0} Transition Function Benny Chor (Tel Aviv University) Computational Models, Class 6 November 23, 2015 31 / 75
Example B = {w#w w {0, 1} } TM formal definition Recall that we saw a pseudo code earlier in the class. Definition 11 (M 1 = (Q, Σ, Γ, δ, q 1, q a, q r )) Q = {q 1,..., q 14, q a, q r }. Σ = {0, 1, #} input alphabet Γ = {0, 1, #, x, } tape alphabet q 1 start state q a accept state q r reject state Benny Chor (Tel Aviv University) Computational Models, Class 6 November 23, 2015 32 / 75
Example B = {w#w : w {0, 1} } Transition Function Benny Chor (Tel Aviv University) Computational Models, Class 6 November 23, 2015 33 / 75
Example: C = {a i b j c k : i j = k i, j, k 1} Algorithm 12 (A TM deciding C (pseudocode)) 1 Scan from left to right to check that input is a + b + c + 2 Return to start of tape 3 Cross off one a and scan right until b occurs. Shuttle between b s and c s, crossing off one of each, until all b s are gone. 4 Restore the crossed-off b s and repeat previous step if more a s exist. If all a s crossed off, check if all c s crossed off. If yes, accept, otherwise reject. Benny Chor (Tel Aviv University) Computational Models, Class 6 November 23, 2015 34 / 75
Example: Element Distinctness Consider the element distinctness problem E = {#x 1 #x 2 #... #x l : x i {0, 1} i j = x i x j } Verbally, List of strings in {0, 1} separated by # s. List is in language (& machine should accept), if all strings are different. Benny Chor (Tel Aviv University) Computational Models, Class 6 November 23, 2015 35 / 75
Decider for E = {#x 1 #x 2 #... #x l : x i {0, 1} i j = x i x j } Algorithm 13 (A TM deciding E (pseudocode)) Input: w 1 Place a mark" on leftmost tape symbol. If symbol not #, reject. 2 Scan right to next # and place mark on top. If none, reject. 3 Compare the two strings to right of marked # s (how?). If equal, reject. 4 If possible, move rightmost mark to next # on right and go to Step 3. 5 If possible, move leftmost mark to next # on right and rightmost mark to # after that, and go to Step 3. 6 Accept. Benny Chor (Tel Aviv University) Computational Models, Class 6 November 23, 2015 36 / 75
Decider for E = {#x 1 #x 2 #... #x l : x i {0, 1} i j = x i x j } #011#00#1111 Ok #011#00#1111 #011#00#1111 #011#00#1111 Question 14 How do we mark a symbol? Answer: For each tape symbol #, add tape symbol # to the tape alphabet Γ. Benny Chor (Tel Aviv University) Computational Models, Class 6 November 23, 2015 37 / 75
Part III Alternative Strong Models of Computing Benny Chor (Tel Aviv University) Computational Models, Class 6 November 23, 2015 38 / 75
Turing Machine Variants For example, suppose the Turing machine head is allowed to stay put. δ : Q Γ Q Γ {L, R, S} Question 15 Does this add any power? Answer: No. Replace each S transition with two transitions: R then L. (ahmm... why not vice-versa?) Important notion here: Two-way emulation (model A capable of emulating model B; model B capable of emulating model A). Benny Chor (Tel Aviv University) Computational Models, Class 6 November 23, 2015 39 / 75
Multitape Turing Machines Constant number of infinite tapes Each tape has its own head Initially, input string on tape 1 and rest blank For the transition function: δ : Q Γ k Q Γ k {L, R} k, the expression δ(q i, a 1,..., a k ) = (q j, b 1,..., b k, L, R,..., L) means: Assuming the machine is in state q i and heads 1 through k reading a 1,..., a k : the machine goes to state q j, heads 1 thought k write b 1,..., b k, each head moves right or left as specified. Benny Chor (Tel Aviv University) Computational Models, Class 6 November 23, 2015 40 / 75
Equivalence Of Multitape TM and Singletape TM Theorem 16 A singletape TM can emulate a multitape TM. Corollary 17 A language is enumerable [resp., decidable], if and only if there is some multitape Turing machine that accepts [resp., decides] it. One direction is trivial. To prove the other direction, we will show how to convert a multitape TM, M, into an equivalent singletape TM, S. Benny Chor (Tel Aviv University) Computational Models, Class 6 November 23, 2015 41 / 75
Emulation Idea 1 1... a b a... x... 1 1 # a b a # x #... S emulates k tapes of M by storing them all on a single tape with delimiter #. S marks the current positions of the k heads by placing above the letters in current positions. It knows which tape the mark belongs to by counting (up to k) from the # s to the left. Benny Chor (Tel Aviv University) Computational Models, Class 6 November 23, 2015 42 / 75
The Emulator Algorithm 18 (The Emulator (pseudocode)) On input w = w 1 w n : 1 Write on the tape # w 1 w 2 w n # # # # 2 Scan the tape from first # to (k + 1)-st # to read symbols under virtual heads. 3 Rescan the tape to write new symbols and move heads 4 When M moves head onto unused blank square, S will try to move virtual head onto #. S handles it by writing blank on tape, and shifting the rest of tape one square to the right. Benny Chor (Tel Aviv University) Computational Models, Class 6 November 23, 2015 43 / 75
Random Access Machine (RAM) CPU 3 Registers (Instruction Register (IR), Program Counter (PC), Accumulator (ACC)) Memory Operation: Increment PC Set IR MEM[PC] Execute instruction in IR Repeat Instructions are typically compare, add/subtract, multiply/divide, shift left/right. We assume no limit on the registers size All instructions above (as well as other common instructions) are doable on a TM but implementing them requires some work. Benny Chor (Tel Aviv University) Computational Models, Class 6 November 23, 2015 44 / 75
RAM: Schematic Picture Benny Chor (Tel Aviv University) Computational Models, Class 6 November 23, 2015 45 / 75
RAM: Instructions Instruction Meaning 00 HALT Stop Computation 01 LOAD x ACC MEM[x] 02 LOADI x ACC x 03 STORE x MEM[x] ACC 04 ADD x ACC ACC + MEM[x] 05 ADDI x ACC ACC + x 06 SUB x ACC ACC - MEM[x] 07 SUBI x ACC ACC - x 08 JUMP x PC x 09 JZERO x PC x if ACC = 0 10 JGT x PC x if ACC > 0 Benny Chor (Tel Aviv University) Computational Models, Class 6 November 23, 2015 46 / 75
RAM: Example Program A program that multiplies two numbers (in locations 1000 & 1001), and stores the result in 1002 Memory Machine Code Assembly 0001 011000 LOAD 1000 0002 031003 STORE 1003 0003 020000 LOADI 0 0004 031002 STORE 1002 0005 021003 LOAD 1003 0006 090013 JZERO 0013 0007 070001 SUBI 1 0008 031003 STORE 1003 0009 011002 LOAD 1002 0010 041001 ADD 1001 0011 080004 JUMP 4 0013 000000 HALT Benny Chor (Tel Aviv University) Computational Models, Class 6 November 23, 2015 47 / 75
TM is (at least) as strong as RAM Theorem 19 A Turing machine can emulate this RAM model. Proof s idea: We can emulate the RAM model with a multi-tape Turing machine: One tape for each register (IR, PC, ACC) One tape for the Memory Memory tape will be entries of the form <address> <contents> in increasing order of addresses. Benny Chor (Tel Aviv University) Computational Models, Class 6 November 23, 2015 48 / 75
Emulator s Tapes Benny Chor (Tel Aviv University) Computational Models, Class 6 November 23, 2015 49 / 75
The Emulator Algorithm 20 (Emulator (high-level description)) 1 Scan through memory until reach an address that matches the PC 2 Copy contents of memory at that address to the IR 3 Increment PC 4 Based on the instruction code: Copy a value into PC Copy a value into Memory Copy a value into the ACC Perform an arithmetic operation, a shift, or a comparison Benny Chor (Tel Aviv University) Computational Models, Class 6 November 23, 2015 50 / 75
Beyond RAM A RAM can be modeled (emulated) by a Turing Machine. Any current machine (architecture, manufacturer, operating system, power supply, etc.) can be modeled by a Turing Machine. If there is an algorithm for it, a Turning Machine can do it. Note that at this point, we don t care how long it might take, just that it can be done. Benny Chor (Tel Aviv University) Computational Models, Class 6 November 23, 2015 51 / 75
Turing Completeness A computation model is called Turing Complete if it can emulate a (general) Turing Machine. Turing Complete can compute anything a TM could Of course it might not be convenient... Benny Chor (Tel Aviv University) Computational Models, Class 6 November 23, 2015 52 / 75
And Now for Something Completely Different: The Church Turing Thesis A stormy day at Tel Aviv, looking south west over the marina, November 26, 2014. Benny Chor (Tel Aviv University) Computational Models, Class 6 November 23, 2015 53 / 75
Part IV Church-Turing Thesis Benny Chor (Tel Aviv University) Computational Models, Class 6 November 23, 2015 54 / 75
What is an Algorithm? Informally: 1 A recipe 2 A procedure 3 A computer program 4 Who cares? I know it when I see it :-( 5 The notion of algorithm has long history in Mathematics (starting with Euclid s gcd algorithm), but not precisely defined until 20 th century Informal notions rarely questioned, still they were insufficient Benny Chor (Tel Aviv University) Computational Models, Class 6 November 23, 2015 55 / 75
Computation Model Many models have been proposed for general-purpose computation. Remarkably, all reasonable models were shown to be equivalent to Turing machines. The notion of an algorithm is model-independent! We don t really care about Turing machines per se. We do care about understanding computation, and because of their simplicity, Turing machines are a good model to use. Benny Chor (Tel Aviv University) Computational Models, Class 6 November 23, 2015 56 / 75
Models Equivalent to TM. All reasonable programming languages (e.g., Java, Pascal, C, Python, Scheme, Mathematica, Maple, Cobol,... ). λ-calculus of Alonzo Church Turing machines of Alan Turing Recursive functions of Godel and Kleene Counter machines of Minsky Normal algorithms of Markov Unrestricted grammars Two stack automata Random access machines (RAMs) Benny Chor (Tel Aviv University) Computational Models, Class 6 November 23, 2015 57 / 75
Church-Turing Thesis The intuitive notion of reasonable models of computation equals Turing machine algorithms. Benny Chor (Tel Aviv University) Computational Models, Class 6 November 23, 2015 58 / 75
Wild" Models of Computation Consider MUntel s ℵ-AXP16 c processor (to be released, Jan. 2016...) Definition 21 (ℵ-AXP16 c ) Like a Turing machine, except Takes first step in 1 second. Takes second step in 1/2 second. Takes i-th step in 2 i seconds... After 2 seconds, the ℵ-AXP16 c decides any enumerable language! Question 22 Does the ℵ-AXP16 c invalidate the Church-Turing Thesis? Benny Chor (Tel Aviv University) Computational Models, Class 6 November 23, 2015 59 / 75
Part V Non-Deterministic Turing Machines Benny Chor (Tel Aviv University) Computational Models, Class 6 November 23, 2015 60 / 75
Non-Deterministic Turing Machines Transition function: δ : Q Γ P(Q Γ {L, R}) Computation of a deterministic TM can be viewed as a path in configuration space. Computation of a non-deterministic TM (NTM) can be viewed as a tree in configuration space. NTM accepts an input if there is ( ) an accepting branch in its computation tree. NTM rejects an input if all ( ) branches in its computation tree are either rejecting or infinite (looping). Benny Chor (Tel Aviv University) Computational Models, Class 6 November 23, 2015 61 / 75
Equivalence of TM and NTM Theorem 23 A Turing Machine can emulate a non-deterministic Turing machine. Corollary 24 A language is enumerable [resp., recursive], if and only if there is some non-deterministic Turing machine that accepts [resp., decides] it. One direction is trivial. To prove the other direction, we will show how to convert a non-deterministic TM, N, into an equivalent deterministic TM, D. Benny Chor (Tel Aviv University) Computational Models, Class 6 November 23, 2015 62 / 75
Basic idea D tries all possible branches If D finds any accepting branch, it accepts. If all branches reject, D rejects. If all branches reject or loop, D loops. Benny Chor (Tel Aviv University) Computational Models, Class 6 November 23, 2015 63 / 75
Emulator s Tapes 1 1... a b #... 1 2 3 3... input tape (never altered) simulation tape address tape The emulating machine D has three tapes Input tape is never altered (only read from), Emulation tape serves as N s tape, Address tape keeps track of D s location in N s computation tree. Benny Chor (Tel Aviv University) Computational Models, Class 6 November 23, 2015 64 / 75
Computation Tree We view N s non-deterministic computation as a tree in the configurations space. Each tree branch is a branch of N s non-deterministic computation Each tree node is a configuration of N Root is starting configuration The number of children of each node, denoted by b, is at most the number of N s states, times the size of Γ, times 2 (left/right). D traverses this tree until if finds an accepting configuration (if any). Question 25 How to traverse this tree? depth-first search? breadth-first search? Benny Chor (Tel Aviv University) Computational Models, Class 6 November 23, 2015 65 / 75
Address Tape The address tape contains a pointer into the configuration tree. Concretely, a string in Σ b, where Σ b = {1,..., b}. Definition 26 By incrementing the value of the address tape, we mean increasing its value by 1 (in base b). Question 27 Can a TM implement the increment function? Question 28 Can a TM compute the value of the node indexed by the address tape (with respect to to a given input w)? Benny Chor (Tel Aviv University) Computational Models, Class 6 November 23, 2015 66 / 75
Simulating Non-Determinism (1) The address tape: every node in the tree has at most b children every node in the tree is assigned an address that is a string over the alphabet Σ b = {1, 2,..., b} to get to node with address 231 start at root take second child of root take third child of current node take first child of current node ignore meaningless addresses (choices not available for configuration along branch) Benny Chor (Tel Aviv University) Computational Models, Class 6 November 23, 2015 67 / 75
Simulating Non-Determinism (2) Initially, the input tape contains w, and the other two tapes are empty. Copy input tape to simulation tape. Use simulation tape to simulate N on input w on a finite portion of one non-deterministic branch. On each choice, consult the next symbol on address tape. Accept if accepting configuration reached. Skip to next step if symbols on address tape exhausted non-deterministic choice invalid rejecting configuration reached Replace string on address tape with the lexicographically next string. Jump to Step 2 to simulate this branch of N s computation. Benny Chor (Tel Aviv University) Computational Models, Class 6 November 23, 2015 68 / 75
The Emulator Algorithm 29 (Emulator (pseudocode)) 1 Compute the configuration of N indexed by the address tape : 1 Copy input tape (i.e., w) to emulation tape. 2 Use emulation tape to emulate the run of N on w, using the address tape to resolve non-deterministic choices. Break current emulation, if symbols on address tape are exhausted (i.e., end of branch) non-deterministic choice is invalid rejecting configuration was reached 2 Accept if accepting configuration reached. 3 Increment the value of address tape. 4 Go back to 1. Benny Chor (Tel Aviv University) Computational Models, Class 6 November 23, 2015 69 / 75
Part VI Decidability vs. Enumerability Benny Chor (Tel Aviv University) Computational Models, Class 6 November 23, 2015 70 / 75
Decidability vs. Enumerability (R = RE co RE) R the class of decidable languages. RE the class of enumerable languages co RE the class of languages whose complement is enumerable co RE = {L : L RE} L R = L RE L R = L R Thm (next slide): R = RE co RE Benny Chor (Tel Aviv University) Computational Models, Class 6 November 23, 2015 71 / 75
Theorem R = RE co RE Theorem 30 R = RE co RE. Proof: R RE co RE L R = L RE L R = L R = L RE = L co RE R RE co RE For L RE co RE, let M 1 be a TM that accepts L, and let M 2 be a TM that accepts L. Benny Chor (Tel Aviv University) Computational Models, Class 6 November 23, 2015 72 / 75
Algorithm for Deciding L Algorithm 31 (M - a decider for L) Input: w. Run both M 1 and M 2 in in parallel". Accept if M 1 accepts Reject if M 2 accepts We next show that M decides L. Benny Chor (Tel Aviv University) Computational Models, Class 6 November 23, 2015 73 / 75
M decides L Claim 32 M decides L Proof: Every string is in either L or in L (of course not in both). Thus either M 1 or M 2 accepts the input w. Since M halts whenever M 1 or M 2 accepts, M always halts (and hence is a decider). Moreover, M accepts strings in L and rejects strings in L. Benny Chor (Tel Aviv University) Computational Models, Class 6 November 23, 2015 74 / 75
Emulating TM s In Parallel Question 33 Hey - what does it mean to emulate M 1, M 2 in parallel? Answer: M has two tapes, one for each machine. Algorithm 34 (TM M) Do (forever) 1 Emulate the next step of M 1 2 Emulate the next step of M 2 3 If this is accepting configuration for some M i, halt and return i. Benny Chor (Tel Aviv University) Computational Models, Class 6 November 23, 2015 75 / 75
Revised (Brave New) View of the World of Languages Artwork on board. Benny Chor (Tel Aviv University) Computational Models, Class 6 November 23, 2015 76 / 75