INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.

Slides:



Advertisements
Similar presentations
Measuring Time Complexity
Advertisements

Turing Machines Memory = an infinitely long tape Persistent storage A read/write tape head that can move around the tape Initially, the tape contains only.
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
Lecture 16 Deterministic Turing Machine (DTM) Finite Control tape head.
Variants of Turing machines
Foundations of (Theoretical) Computer Science Chapter 3 Lecture Notes (Section 3.2: Variants of Turing Machines) David Martin With.
CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Variants.
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
CS21 Decidability and Tractability
1 Introduction to Computability Theory Lecture14: Recap Prof. Amos Israeli.
Measuring Time Complexity Sipser 7.1 (pages )
More Turing Machines Sipser 3.2 (pages ). CS 311 Fall Multitape Turing Machines Formally, we need only change the transition function to.
More Turing Machines Sipser 3.2 (pages ).
CFG => PDA Sipser 2 (pages ). CS 311 Fall Formally… A pushdown automaton is a sextuple M = (Q, Σ, Γ, δ, q 0, F), where – Q is a finite set.
Complexity ©D.Moshkovitz 1 Turing Machines. Complexity ©D.Moshkovitz 2 Motivation Our main goal in this course is to analyze problems and categorize them.
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
Fall 2003Costas Busch - RPI1 Decidability. Fall 2003Costas Busch - RPI2 Recall: A language is decidable (recursive), if there is a Turing machine (decider)
CS 302: Discrete Math II A Review. An alphabet Σ is a finite set (e.g., Σ = {0,1}) A string over Σ is a finite-length sequence of elements of Σ For x.
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY Read sections 7.1 – 7.3 of the book for next time.
1 The Chomsky Hierarchy. 2 Unrestricted Grammars: Rules have form String of variables and terminals String of variables and terminals.
CS 310 – Fall 2006 Pacific University CS310 Turing Machines Section 3.1 November 6, 2006.
Programming the TM qa  (,q) (,q) q1q1 0q1q1 R q1q1 1q1q1 R q1q1  h  Qa  (,q) (,q) q1q1 0q2q2  q1q1 1q3q3  q1q1  h  q2q2 0q4q4 R q2q2 1q4q4.
Fall 2004COMP 3351 The Chomsky Hierarchy. Fall 2004COMP 3352 Non-recursively enumerable Recursively-enumerable Recursive Context-sensitive Context-free.
Lecture 5 Turing Machines
Computation Theory Introduction to Turing Machine.
Linear Bounded Automata LBAs
CS 490: Automata and Language Theory Daniel Firpo Spring 2003.
CS5371 Theory of Computation Lecture 10: Computability Theory I (Turing Machine)
Fall 2006Costas Busch - RPI1 Undecidable Problems (unsolvable problems)
Prof. Busch - LSU1 Undecidable Problems (unsolvable problems)
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
Introduction to CS Theory Lecture 15 –Turing Machines Piotr Faliszewski
CSE 3813 Introduction to Formal Languages and Automata Chapter 10 Other Models of Turing Machines These class notes are based on material from our textbook,
 2005 SDU Lecture13 Reducibility — A methodology for proving un- decidability.
1Computer Sciences Department. Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER Reference 3Computer Sciences Department.
D E C I D A B I L I T Y 1. 2 Objectives To investigate the power of algorithms to solve problems. To explore the limits of algorithmic solvability. To.
CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Turing Machines.
Umans Complexity Theory Lectures Lecture 1b: Turing Machines & Halting Problem.
1 The Chomsky Hierarchy. 2 Unrestricted Grammars: Productions String of variables and terminals String of variables and terminals.
Summary of Previous Class There are languages that are not decidable –(we have not proved this yet) Why not extend Turing machines just as we did with.
CSCI 3130: Formal languages and automata theory Andrej Bogdanov The Chinese University of Hong Kong Decidable.
The Church-Turing Thesis
CSCI 2670 Introduction to Theory of Computing September 29, 2005.
FORMAL LANGUAGES, AUTOMATA, AND COMPUTABILITY * Read chapter 4 of the book for next time * Lecture9x.ppt.
Lecture 11  2004 SDU Lecture7 Pushdown Automaton.
Costas Busch - RPI1 Decidability. Costas Busch - RPI2 Another famous undecidable problem: The halting problem.
Recursively Enumerable and Recursive Languages. Definition: A language is recursively enumerable if some Turing machine accepts it.
Decidability.
Recursively Enumerable Languages
CSCI 2670 Introduction to Theory of Computing
Busch Complexity Lectures: Reductions
Undecidable Problems Costas Busch - LSU.
Reductions Costas Busch - LSU.
CS21 Decidability and Tractability
CS154, Lecture 7: Turing Machines.
CSCI 2670 Introduction to Theory of Computing
Busch Complexity Lectures: Undecidable Problems (unsolvable problems)
CS154, Lecture 8: Undecidability, Mapping Reductions
Intro to Theory of Computation
CS154, Lecture 8: Undecidability, Mapping Reductions
Non-Deterministic Finite Automata
Decidable Languages Costas Busch - LSU.
Non Deterministic Automata
Undecidable problems:
CS21 Decidability and Tractability
Decidability and Tractability
Variants of Turing machines
Intro to Theory of Computation
Presentation transcript:

INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011

THE 4011… First model of a program: DFA / Regexp Solvable Problems: Regular Languages Unsolvable Problems: { 0 n 1 n | n ≥ 0 } Next model of a program: PDA / CFG Solvable Problems: Context-Free Languages Unsolvable Problems: { w#w | w ∈  * } def is_duplicate(s): n = int(len(s)/2) if (s[n]!= ‘#’: return False return s[:n] == s[n+1:]

TURING MACHINE FINITE STATE CONTROL UNBOUNDED TAPE INPUT q0q0 q1q1 A

0 → 0, R readwritemove  → , R q accept q reject 0 → 0, R  → , R 0 → 0, R  → , L A TM can loop forever!

TMs VERSUS FINITE AUTOMATA TM can both write to and read from the tape The head can move left and right The string doesn’t have to be read entirely Accept and Reject take immediate effect

Testing membership in B = { w#w | w  {0,1}* } STATE 011# 0 11 q 0, FIND # q GO LEFT 0 q 1, FIND # q #, FIND  #1 q 0, FIND  0 q 1, FIND  1 x x x

Definition: A Turing Machine is a 7-tuple T = (Q, Σ, Γ, , q 0, q accept, q reject ), where: Q is a finite set of states Γ is the tape alphabet, where   Γ and Σ ⊂ Γ q 0  Q is the start state Σ is the input alphabet, where   Σ  : Q  Γ → Q  Γ  {L,R} q accept  Q is the accept state q reject  Q is the reject state, and q reject  q accept

CONFIGURATIONS 11010q q7q

0 → , R  → , R q accept q reject 0 → x, R x → x, R  → , R x → x, R 0 → 0, L x → x, L x → x, R  → , L  → , R 0 → x, R 0 → 0, R  → , R x → x, R { 0 | n ≥ 0 } 2n2n q0q0 q1q1 q2q2 q3q3 q4q4

0 → , R  → , R q accept q reject 0 → x, R x → x, R  → , R x → x, R 0 → 0, L x → x, L x → x, R  → , L  → , R 0 → x, R 0 → 0, R  → , R x → x, R { 0 | n ≥ 0 } 2n2n q0q0 q1q1 q2q2 q3q3 q4q4 q  q  xq 3 00  x0q 4 0  x0xq 3  x0q 2 x  xq 2 0x  q 2 x0x q 2  x0x

EXAMPLES Give TM state diagrams for: { a n b n a n | n ≥ 0 } { w | w = w R }

ADD = {1 i #1 j #1 k | i+j = k} 11#111#11111 x1#111#z1111 xx#111#zz111 xx#x11#zzz11 xx#xx1#zzzz1 xx#xxx#zzzzz

q 0 : 0 # FIND-1-L # →#,R q 4 : 1 # FIND-1-L q 1 : 0 # FIND-1-R 1→x,R q 3 : 1 # FIND-1-R # →#,R 1→1,R q 6 : 2 # REJ-1-R # →#,R z→z,R q R : REJECT 1 →1,R # →#,L 1→x,R q a : ACCEPT □ → □,L q 7 : 2 # FIND-1-R □ → □,L # →#,L z→z,R q 8 : 2 # FIND-x-L # →#,R 1→z,L q 5 : 1 # FIND-x-L # →#,L Z→z,L x→x,R 1→1,L q 2 : 0 # FIND-x-L # →#,L 1→1,L x→x,R 1→1,R

MUL = {1 i #1 j #1 k | ij = k and i, j, k ≥ 1} 11#111# x1#111# x1#yyy#zzz111 x1#111#zzz111 xx#yyy#zzzzzz

LUP = {1 i #x 1 #...#x n | n ≥ i and x i = x 1 } 111#101#11#101 x11#101#11#101 xx1#101#11#101 xxx#101#11#

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 language L if it accepts all and only the strings in L.

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.

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.

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

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

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 )

Theorem: multi-tape TMs are equivalent to ordinary TMs: ⇐ : a multi-tape TM can run a single-tape TM by ignoring its extra tapes. L is decided by a multi-tape TM ⇔ L is decided by a single-tape TM. ⇒ : Next Lecture…