input output assumptions
play

Input/Output Assumptions I/O Assumption Input: Finite string of - PowerPoint PPT Presentation

Input/Output Assumptions I/O Assumption Input: Finite string of bits, i.e., sequence of 0s and 1s. Output: Finite string of bits. Computation and Turing Machines Claim Without loss of generality, one can always assume the above input.


  1. Input/Output Assumptions I/O Assumption Input: Finite string of bits, i.e., sequence of 0’s and 1’s. Output: Finite string of bits. Computation and Turing Machines Claim Without loss of generality, one can always assume the above input. Nabil Mustafa Set of all strings of length n denoted by { 0 , 1 } n . Set of all strings: { 0 , 1 } ∗ = � n ≥ 0 { 0 , 1 } n Computability and Complexity Can represent Integers Alphabets Graphs, using adjacency matrix Use ⌊ x ⌋ to represent the encoding of x Nabil Mustafa Computation and Turing Machines Nabil Mustafa Computation and Turing Machines Representing tuples Representing Problems Example Problem: Given a graph G = ( V , E ) and an integer k , does there Use notation � x , y � to represent the pair x and y exist an independent of size k in G ? Can encode � x , y � as follows: Answer is a ‘yes’ or a ‘no’ Can encode output ‘yes’ by 1 and ‘no’ by 0 First encode � x , y � as ⌊ x ⌋ # ⌊ y ⌋ Can assume that G is given by a string of bits. Use mapping 0 → 00, 1 → 11, and # → 01, Then, can model this problem by a boolean function. Can decode properly by Boolean function Given a boolean function f : { 0 , 1 } ∗ → { 0 , 1 } , define Scanning left to right, Read two consecutive bits and decode L f = { x : f ( x ) = 1 } as the set of inputs on which f accepts x . Nabil Mustafa Computation and Turing Machines Nabil Mustafa Computation and Turing Machines

  2. Languages Computation Computation Boolean function Given a boolean function f : { 0 , 1 } ∗ → { 0 , 1 } , define Given the input ⌊ G ⌋ how exactly does f compute f ( ⌊ G ⌋ )? L f = { x : f ( x ) = 1 } There is an algorithm for computing f ( ⌊ G ⌋ ) as the set of inputs on which f accepts x . Enumerate over all k -tuples of vertices of G For each k -tuple, check if it is an independent set. The function f defines the language L f For example, L f is equivalent to: Construct a computing machine that runs any algorithm Input and output storage. L f = {⌊ G ⌋◦⌊ k ⌋ : ∃ S ⊂ V s . t . | S | = k and ∀ u , v ∈ S , ( u , v ) / ∈ E } Code to represent the algorithm (e.g., in C++, Java) Computational Problem Computation machine Given the input ⌊ G ⌋ , compute f ( ⌊ G ⌋ )? Details of such a machine? Nabil Mustafa Computation and Turing Machines Nabil Mustafa Computation and Turing Machines Storage Storage Use Tape for storage: infinite one-dimensional line of cells Our machine uses: Each cell contains exactly one symbol from our alphabet 1 input tape: binary strings written on it represent the input Each tape has a tape head , positioned on one cell The tape head can only move to the cell to the left or right. 1 output tape: once the machine computes the answer, it is Write a new symbol to the current cell only written on the output tape 1 work tape: initially empty tape which the machine uses as a 1 0 0 0 0 0 0 ‘scratch pad’. Code How is the code of the machine represented? Nabil Mustafa Computation and Turing Machines Nabil Mustafa Computation and Turing Machines

  3. Turing machine Transition Function A Turing machine ( TM ) is a tuple M = (Γ , Q , δ ) where At each step, TM is in some state, say q TM reads a symbol from input tape, and working tape, say s 1 Γ: set of symbols that TM ’s tapes can contain. and s 2 . � : symbols denoting a ‘blank’ ⊲ : the designated start symbol TM looks up the transition function: { 0 , 1 } δ ( q , ( s 1 , s 2 )) → q ′ , t 2 , { L , S } Q : possible states TM can be in. A special register stores the current state. TM then: q start : the TM starts in this state q halt : the TM halts when this state is reached changes state to q ′ overwrites the symbol s 2 with t 2 on work-tape The code δ : Q × Γ 2 → Q × Γ × { L , R , S } . δ is called the moves the input tape head to the left, the tape head of the working tape stays same transition function. Nabil Mustafa Computation and Turing Machines Nabil Mustafa Computation and Turing Machines Example Working of the example TM Q IT Γ Q OT Γ { L , S , R } Only one input and one output tape. No work tape. − R q start ⊲ q 1 States Q = { q start , q 1 , q halt } 0 − R q 1 q 1 1 1 S q 1 q halt Symbols Γ = { 0 , 1 , ⊲ , � } 0 S q 1 � q halt Transition function δ : Q IT Γ Q OT Γ { L , S , R } q start q 1 − R ⊲ q 1 0 q 1 − R 0 0 1 1 0 0 q 1 1 q halt 1 S q 1 � q halt 0 S What does this TM do? Step 5: State = q halt with Accept Nabil Mustafa Computation and Turing Machines Nabil Mustafa Computation and Turing Machines

  4. Program size Running time Question TM halts and outputs one of { 0 , 1 } For a TM = (Γ , Q , δ ) , what is the size of the table given by δ ? Running time of a TM is number of steps from start to end. TM does not halt (e.g., infinite loops) Running time is undefined. δ : Q × Γ 2 → Q × Γ × { L , R , S } Different inputs take different steps Size of δ solely determined by | Q | and | Γ | Running time Given: Hence total size: | Q | · | Γ | · | Γ | A Turing machine M f : { 0 , 1 } ∗ → { 0 , 1 } T : N → N This is a constant if | Q | and | Γ | are constant. we say that M computes f in T ( n )-time if for every x ∈ { 0 , 1 } ∗ , M computes f ( x ) in at most T ( | x | ) steps. Note that different δ ’s might define the same behavior. Nabil Mustafa Computation and Turing Machines Nabil Mustafa Computation and Turing Machines Palindrome testing 3-tape TM for PAL Algorithm : PAL ( x ) = 1 if x is a palindrome, 0 otherwise. This defines a language: Copy the input string to the work-tape L PAL = { x ∈ { 0 , 1 } ∗ : PAL ( x ) = 1 } Move the tape head of input-tape to the start At each step, move the tape head of input-tape forward, Examples of palindromes: work-tape backward. And then check for same symbols. 00001010000 , AVIVA , 11111111111111 , 1010101001010101 Each of these tasks done via a state. While the TM is in that state, its doing that task. Q Problem q start , q copy , q moveleft , q test , q halt Given a string x , construct a TM that computes PAL ( x ). Nabil Mustafa Computation and Turing Machines Nabil Mustafa Computation and Turing Machines

  5. 3-tape TM for PAL 3-tape TM for PAL q start : Just go into the q copy state. q moveleft : q copy : Keep moving the input tape-head left till it hits the start Till the end of input tape is reached, keep copying input tape symbol. Let the work-tape head stay at the right. to work tape. Γ 2 Γ 2 { L , S , R } 3 Q Q Γ 2 Γ 2 { L , S , R } 3 Q Q q moveleft 0 , ∗ q moveleft ( − , − ) ( L , S , S ) ⊲ , ∗ ( ⊲ , − ) ( R , R , S ) q start q copy q moveleft 1 , ∗ q moveleft ( − , − ) ( L , S , S ) 0 , ∗ (0 , − ) ( R , R , S ) q copy q copy q moveleft ⊲ , ∗ q test ( − , − ) ( R , S , S ) 1 , ∗ (1 , − ) ( R , R , S ) q copy q copy � , ∗ ( − , − ) ( L , L , S ) q copy q moveleft *: perform for all possible symbols Nabil Mustafa Computation and Turing Machines Nabil Mustafa Computation and Turing Machines 3-tape TM for PAL 3-tape TM for PAL q test : At each step: Time taken: O ( n ) advance input-tape head to the right work-tape head to the left, check if the symbols are the same. Question Γ 2 Γ 2 { L , S , R } 3 Q Q Assume only input tape. Then how fast can one compute PAL ( x ) ? q test 1 , 1 q test ( − , − ) ( R , L , S ) q test 0 , 0 q test ( − , − ) ( R , L , S ) q test 0 , 1 q halt ( − , 0) ( S , S , S ) Answer: Ω( n 2 )! q test 1 , 0 q halt ( − , 0) ( S , S , S ) q test � , ⊲ , ∗ q halt ( − , 1) ( S , S , S ) Nabil Mustafa Computation and Turing Machines Nabil Mustafa Computation and Turing Machines

  6. Lower-bound for 1-tape TM Lower-bound for 1-tape TM Proof. Claim Goal: From 2 n strings, there is a string taking Ω( n 2 ) time. Any 1-tape TM takes Ω( n 2 ) steps to compute PAL ( x ) , | x | = n. Show stronger statement: ∃ from a set of 2 n / 3 strings Specifically, for any TM and any n, there exists a string x, | x | = n, such that TM takes Ω( n 2 ) to check if x is a palindrome. Let m = n / 3. Then, for any string | x | = m , define P ( x , y ) = x ◦ { 0 } m ◦ y r P ( x , x ) is a palindrome Proof by counting by averaging. T ( x ): running time of P ( x , x ) , T ( n ) = max x , | x | = n T ( x ). Fix a Turing machine for computing PAL , say the TM M . We will count the following: Lets assume the worst-case running time (over all n -sized d · n 2 · 2 m ≤ T ( x ) ≤ 2 m · T ( n ) � strings) is T ( n ) x ∈{ 0 , 1 } m Goal: lower-bound T ( n ) Nabil Mustafa Computation and Turing Machines Nabil Mustafa Computation and Turing Machines Lower-bound for 1-tape TM Lower-bound for 1-tape TM To prove claim, count the sum of the running times T ( x ) Our first trivial claim is that T ( x ) ≤ 2 m · T ( n ) � x ∈{ 0 , 1 } m This holds trivially because the number of strings of length m are 2 m and T ( n ) is the worst case running time over all n sized strings which would obviously be greater than any T ( m ) The second harder claim holds the key to entire proof. d · n 2 · 2 m ≤ � T ( x ) x ∈{ 0 , 1 } m Putting together the two claims = ⇒ ∃ a string of size n / 3 C ( x , y , c ): the sequence of states of Q in which M crosses the taking Ω( n 2 ) time for PAL ( x ) function. cut c when executed on the string P ( x , y ) Nabil Mustafa Computation and Turing Machines Nabil Mustafa Computation and Turing Machines

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