homework
play

Homework Homework #5 Turing Machines Returned today Homework - PDF document

Homework Homework #5 Turing Machines Returned today Homework #7 (due Thursday) Help after lecture And the languages they handle Before We Start Languages Any questions? Is that your final answer? What is a


  1. Homework • Homework #5 Turing Machines – Returned today • Homework #7 (due Thursday) – Help after lecture And the languages they handle Before We Start Languages • Any questions? • Is that your final answer? – What is a language? – What is a class of languages? Now our picture looks like Turing Machine • A Machine consists of: Context Free Languages – A state machine Deterministic Context Free Languages – An input tape – A movable r/w tape head Regular Languages • A move of a Turning Machine – Read the character on the tape at the current position of Finite the tape head Languages – Change the character on the tape at the current position of the tape head – Move the tape head We’re going to start to look at – Change the state of the machine based on current state languages out here and character read 1

  2. Turing Machine Turing Machine • In the original Turing Machine • Tape that holds Input tape (input/memory) character string – The read tape was infinite in both directions ... • Movable tape head that – The text describes a semi-infinite TM where Read head reads and writes • The tape is bounded on the left and infinite on the State right character Machine • It can be shown that the semi-infinite TM is • Machine that changes equivalent to the basic TM. (program) state based on what is – As not to confuse, I’ll follow the conventions in read in the book…(as much as that bothers me!) Turing Machines Turing Machines • About the input tape • About the machine states – Bounded to the left, infinite to the right – A Turing Machine does not have a set of accepting states – All cells on the tape are originally filled with a special “blank” character ∆ – Instead, each TM has a special halting state, h. – Tape head is read/write • Once in the halting state, the machine halts. – Unlike PDAs, the basic TM is deterministic! – Tape head can not move to the left of the start of the tape • If it tries, the machine “crashes” Turing Machines Turing Machines • Transition function: • Let’s formalize this – δ : Q x ( Γ ∪ { ∆ }) → (Q ∪ {h}) x ( Γ ∪ { ∆ }) x {R, L, – A Turing Machine M is a 5-tuple: S} – M = (Q, Σ , Γ , q 0 , δ ) where • Q = a finite set of states (assumed not to contain the halting – Input: state h) • Current state • Σ = input alphabet (strings to be used as input) • Tape symbol read at current position of tape head • Γ = tape alphabet (chars that can be written onto the tape. – Output: Includes symbols from Σ ) • State in which to move the machine (can be the halting state) • Both Σ and Γ are assumed not to contain the “blank” symbol • Tape symbol to write at the current position of the tape head • δ = transition function (can be the “blank” symbol) • Direction in which to move the tape head (R = right, L = left, S= stationary) 2

  3. Turing Machine Turing Machine • Accepting a string • Running a Turing Machine – A string x is accepted by a TM, if – The execution of a TM can result in 4 possible cases: • Starting in the initial configuration • With x on the input tape • The machine “halts” (ACCEPT) • The machine has nowhere to go (REJECT) • The machine eventually ends up in the halting state. • The machine “crashes” (REJECT) – I.e. • The machine goes into an “infinite loop” (REJECT • (q 0 , ∆ x) a * (h, xay) but keeps us guessing!) – for x,y ∈ ( Γ ∪ { ∆ }) * , a ∈ ( Γ ∪ { ∆ }) Turing Machine Computation with Turing Machines • Language accepted by a TM • Computing functions with TMs – The language accepted by a TM is the set of all – The result of the function applied to an input input strings x on which the machine halts. string x, will be left on the tape when the machine halts. – Functions with multiple arguments can be placed on the input tape with arguments separated by blanks. • Questions? Computation with Turing Machines Computation with Turing Machines • Computing functions with TMs • Computing functions with TMs – Formally, – Formally (with multiple arguments) • Let T = (Q, Σ , Γ , q 0 , δ ) be a TM and let f be a • Let T = (Q, Σ , Γ , q 0 , δ ) be a TM and let f be a partial function on Σ * . We say T computes f if for partial function on ( Σ *) k . We say T computes f if every x ∈ Σ * where f is defined: for every (x 1 , x 2 . …, x k ) where f is defined: – (q 0 , ∆ x) a * (h, ∆ f(x)) – (q 0 , ∆ x 1 ∆ x 2 … ∆ x k ) a * (h, ∆ f(x 1 , x 2 . …, x k )) • And for every other x, T fails to halt on input x. • And for every other k-tuple, T fails to halt on input x. 3

  4. TMs and languages Computation with Turing Machines • Characteristic function of a set: • Two classes of languages that involve TMs: – For any language L, the characteristic function is – Languages, L accepted by TM defined as: • Halts on x ∈ L, “rejects” on x ∉ L • 1 if x ∈ L • 0 otherwise – Languages, L recognized by a TM • TM computes the characteristic function of L – If a TM computes the characteristic function of a language, it will always halt with either a 1 or 0 left on • Halts on all x the tape • Give yes/no answer as to whether x ∈ L • This is stronger than saying that x is accepted by the TM since if x ∉ L, for a TM that accepts L, there is no guarantee that the the machine will halt. TMs and languages TMs and languages • Two classes of languages that involve TMs: • First observation: – A language is recursively enumerable if there is – Every recursive language is also recursively a TM that accepts it enumerable – A language is recursive if there is a TM that • Modify the TM that recognizes the language so that it goes into a “nowhere state” just before placing the recognizes it. 0 on the tape indicating that a string is not in the language. TMs and languages TMs and languages • Game plan Is there 1. Show that there exists a language that is not something out recursively enumerable here Recursively 2. Show that there exists a language that is Enumerable recursively enumerable but not recursive. Recursive Is there something in here 4

  5. Universal Turing Machine A language that is not recursively enumerable • Universal Turing Machine • Sorry, no pumping Lemma for TMs! – A TM T u that takes as input, an encoded version of another TM M’ and an input to M’. • Instead we introduce the notion of a – M will simulate the processing of M’ Universal Turning Machine • If M’ halts on input x, T u will halt • If M’ rejects on input x,T u will reject. – T u is a general purpose TM • M’ is a program run on the general purpose TM Universal Turing Machine Universal Turing Machine • Encoding scheme • Encoding scheme – We need a way to encode a TM so that it can be – Associate states, symbols, and directions with provided as input to T u binary numbers: – Define sets: • States: • Q = {q 1 , q 2 , … } = set of all possible states that may appear in – s(h) → 0 any TM – s(q i ) → 0 i+1 • S = {a 1 , a 2 , a 3 , …} = set of all possible tapes symbols that can • Symbols be written on any TM. – s( ∆ ) → 0 – So for any TM • Q ⊆ Q and Γ ⊆ S – s(a i ) → 0 i+1 Universal Turing Machine Universal Turing Machine • Encoding scheme • Encoding scheme – Associate states, symbols, and directions with – Encoding transitions: binary numbers: • Encode each state, symbol, direction • Directions: • Separate by 1’a – s(S) → 0 – The transition δ (p,a) = (q, b, D) can be – s(L) → 00 encoded as: – s(R) → 000 • s(p)1s(a)1s(q)1s(b)1s(D) 5

  6. Universal Turing Machine Universal Turing Machine • Encoding • The input to T u will be – Encoding for a TM – an encoded TM and • Encode the start state – a string x to run on that TM • Encode each of it’s moves – We encode x by individually encoding the • Separate by 1’s characters of x (separated by 1’s) – e(T) = s(q)1e(m 1 )1e(m 2 )1…1e(m k )1 • x = z 1 z 2 …z n • e(x) = s(z 1 )1s(z 2 )1…1s(z n )1 Universal Turing Machine Universal Turing Machine • Encoding Scheme • Encoding example – States – Finally, the description of the TM and the • q 0 – state 1 encoding of the string to run on the TM will be • p – state 2 separated by 2 1’s • s – state 3 • Input to T u – Symbols – e(M)11e(x) • a – symbol 1 • b – symbol 2 Universal Turing Machine Universal Turing Machine • Encoding example • Encoding scheme – States – The actual scheme isn’t really important (in • s (h) = 0 • s(q 0 ) = 00 fact, there are many) • s(p) = 000 – What is important is that we can encode a TM • s(r) = 0000 – Symbols and it’s input as a binary string. • s( ∆ ) = 0 • s(a) = 00 00 1 00 1 0 1 000 1 0 1 000 • s(b) = 000 – Directions • s(S) → 0 • s(L) → 00 • s(R) → 000 6

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend