Presentation is loading. Please wait.

Presentation is loading. Please wait.

CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Turing Machines.

Similar presentations


Presentation on theme: "CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Turing Machines."— Presentation transcript:

1 CSC 3130: Automata theory and formal languages Andrej Bogdanov http://www.cse.cuhk.edu.hk/~andrejb/csc3130 The Chinese University of Hong Kong Turing Machines Fall 2009

2 What is a computer? A computer is a machine that manipulates data according to a list of instructions. computer input data instructions (program) output data

3 Are DFAs and PDAs computers? 0,  / a #,  / , Z 0 /  1, a /  0 1 0, 1 A computer is a machine that manipulates data according to a list of instructions. yesno!

4 A short history of computing devices Leibniz calculator (1670s) slide rule (1600s) abacus (Babylon 500BC, China 1300) Babbage’s mechanical engine (1820s)

5 A brief history of computing devices Z3 (Germany, 1941)ENIAC (Pennsylvania, 1945) PC (1980) MacBook Air (2008)

6 Which of these are “real” computers? not programmable programmable

7 Computation is universal In principle, all these computers have the same problem-solving ability C++javapythonLISP

8 The Turing Machine C++javapythonLISP Turing Machine

9 The Turing Machine The Turing Machine is an abstract automaton that is meant to model any physically realizable computer –Using any technology (mechanical, electrical, nano, bio) –Under any physical laws (gravity, quantum, E&M) –At any scale (human, quantum, cosmological) How come there is one model that can capture all these vastly different settings? Why do we need an abstract model of a computer?

10 Computation and mathematical proofs Prove that... √ 2 is irrational. The equation x n + y n = z n, n ≥ 2 has no integer solutions. G = (L, R) has a perfect matching iff |  (S)| ≥ |S| for every L ⊆ S. The language 0 n 1 n is not regular. Math is hard, let’s go shopping! (Archimedes’ Theorem) (Fermat-Wiles Theorem) (Hall’s Theorem)

11 Hilbert’s list of 23 problems Leading mathematician in the 1900s At the 1900 International Congress of Mathematicians, proposed a list of 23 problems for the 20 th century Hilbert’s 10 th problem: David Hilbert (1862-1943) Find a method for telling if an equation like xyz – 3xy + 6xz + 2 = 0 has integer solutions

12 Automated theorem-proving computer input data instructions output √ 2 is irrational. The equation x n + y n = z n, n ≥ 2 has no integer solutions. G = (L, R) has a perfect matching iff |  (S)| ≥ |S| for every L ⊆ S. The language 0 n 1 n is not regular. check if they are true! xyz – 3xy + 6xz + 2 = 0 has integer solutions. true / false

13 Automated theorem proving How could automated theorem proving work? Let’s look at a typical proof: √ 2 is irrational. Assume not. Then √ 2 = m/n. Then m 2 = 2n 2 But m 2 has an even number of prime factors and 2n 2 has an odd number of prime factors. Contradiction. Theorem: Proof:

14 First idea of automated theorem proving Checking that a proof is correct is much easier than coming up with the proof ➀ Proof:... if we write out the proof in sufficient detail √ 2 = m/n both sides ×n ( √ 2)n = m square ( √ 2) 2 n 2 = m 2 def of sqrt 2n 2 = m 2

15 First idea of automated theorem proving Checking that a proof is correct is much easier than coming up with the proof –In principle this is uncontroversial –In practice, it is harder (but still possible) to do ➀ A proof, if written out in sufficient detail, can be checked mechanically

16 Second idea of automated theorem proving To find if statement is true, why don’t we try all possible proofs After all, a proof is just a sequence of symbols (over alphabet {0, 1, 2, m, n, √, 2, etc.} ) If statement is true, it has a proof of finite length, say k To find it, let’s just try all possible proofs of length 1, 2, up to k ➁ √ 2 = m/n ( √ 2)n = m ( √ 2) 2 n 2 = m 2 2n 2 = m 2...

17 Königsberg, 1930 David Hilbert (1862-1943) Kurt Gödel (1906-1978) September 8: Hilbert gives a famous lecture “Logic and the understanding of nature”

18 Königsberg, 1930 David Hilbert (1862-1943) Kurt Gödel (1906-1978) John von Neumann (1903-1957) I reached the conclusion that in any reasonable formal system in which provability in it can be expressed as a property of certain sentences, there must be propositions which are undecidable in it. It is all over!

19 What did Gödel say? To find if statement is true, why don’t we try all possible proofs After all, a proof is just a sequence of symbols (over alphabet {0, 1, 2, m, n, √, 2, etc.} ) If statement is true, it has a proof of finite length, say k To find it, let’s just try all possible proofs of length 1, 2, up to k ➁ NO!

20 Gödel’s incompleteness theorem Some mathematical statements are true but not provable. What are they?

21 Example of incompleteness Recall Hilbert’s 10 th problem: Matyashievich showed in 1970 that there exists a polynomial p such that Find a method for telling if an equation like xyz – 3xy + 6xz + 2 = 0 has integer solutions p(x 1,..., x k ) = 0 has no integer solutions, but this cannot be proved

22 Another example of incompleteness Recall ambiguous context free grammars We did exercises of the type “Show that G is ambiguous” However there exists a CFG G such that G is unambiguous, but this cannot be proved

23 www.logicomix.com

24 Gödel’s incompleteness theorem Some mathematical statements are true but not provable. What does this have to do with computer science?

25 The father of modern computer science Invented the Turing Test to tell humans and computers apart Broke German encryption codes during World War II The Turing Award is the “Nobel prize of Computer Science” Alan Turing (1912-1954) “On Computable Numbers, with an Application to the Entscheidungsproblem” 1936:

26 Turing’s angle on incompleteness computer input data instructions output check if true! true / false mathematical statement Gödel’s theorem says that a computer cannot determine the truth of mathematical statements But there are many other things!

27 Computer program analysis public static void main(String args[]) { System.out.println("Hello World!"); } What does this program do? How about this one? public static void main(String args[]) { int i = 0; for (j = 1; j < 10; j++) { i += j; if (i == 28) { System.out.println("Hello World!"); }

28 Computers cannot analyze programs! computer input data instructions output does it print Hello, world! java program The essence of Gödel’s theorem is that computers cannot analyze computer programs

29 How do you argue things like that? To argue what computers cannot do, we need to have a precise definition of what a computer is. “On Computable Numbers, with an Application to the Entscheidungsproblem” 1936: Section 1. Computing Machines

30 Turing Machines state control … A Turing Machine is a finite automaton with a two-way access to an infinite tape Initially, the first few cells contain the input, and the other cells are blank infinite tape 010 input

31 Turing Machines state control … At each point in the computation, the machine sees its current state and the symbol at the head It can replace the symbol on the tape, change state, and move the head left or right 01a0 head

32 How Turing Machines operate … 01a0 q1q1 q2q2 a/bL Replace a with b, and move head left current state … 01b0 q1q1 q2q2 a/bL current state

33 Formal Definition A Turing Machine is (Q, , , , q 0, q acc, q rej ) : –Q is a finite set of states; –  is the input alphabet; –  is the tape alphabet (    ) including the blank symbol ☐ –q 0 in Q is the initial state; –q acc, q rej in Q are the accepting and rejecting state; –  is the transition function  : (Q – {q acc, q rej })   → Q   {L, R}

34 Operation of Turing Machines Differences from pushdown automata –TM can access arbitrary entries in memory –Transitions in TM are deterministic –TM uses same tape for input and memory … 001 ☐ q0q0 ☐☐☐ Initially, tape contains input followed by blanks

35 Programming Turing Machines L 1 = {w$w: w ∈ { a, b }*} Strategy: Read and remember the first symbol Cross it off ( x ) Read the first symbol past $ If they don’t match, reject abbaa$abbaa xbbaa$abbaa If they do, cross it off xbbaa$xbbaa

36 Programming Turing Machines L 1 = {w$w: w ∈ { a, b }*} Strategy: Look for the first uncrossed symbol Cross it off ( x ) Read the first uncrossed symbol past $ xbbaa$xbbaa xxbaa$xbbaa If they match, cross it off, else reject xxbaa$xxbaa At the end, there should be only x s and $ s xxxxx$xxxxx If not, reject

37 Programming Turing Machines L 1 = {w$w: w ∈ { a, b }*} Description of Turing Machine: Until you reach $ Read and remember entry Move right past $ and past all x s If this entry is different, reject Otherwise Move left past $ and to right of first x If you see only x s followed by ☐, accept xbbaa$xbbaa xxbaa$xxbaa Write x xxbaa$xbbaa Write x xxbaa$xxbaa 1 2 3 4 5 6 7 8

38 Programming Turing Machines L 1 = {w$w: w ∈ {a, b}*} q0q0 q a1 q a2 q2q2 q b1 q b2 q3q3 q rej q1q1 q acc a/xR $/$R b/xL b/xR a/xL a/aR b/bR a/aR b/bR x/xR a/aL b/bL x/xL ☐/☐R☐/☐R $/$R a/aL b/bL x/xR everything else 1 2 3 2 3 4 4 56 56 7 8

39 Programming Turing Machines read a accept write x move right blank

40 Programming Turing Machines L 2 = { $a i b j c k : i  j = k and i, j, k > 0 } Strategy: Scan input from left to right to check it looks like $aa * bb * cc * Move left until you see first a Until all a s have been crossed off ( x ) For every b you see, cross off one of the c s ( z ) Cross off one a ( x ) If there are any uncrossed c s left, reject If there are no c s left, reject Otherwise, accept

41 Programming Turing Machines L 2 = { $a i b j c k : i  j = k and i, j, k > 0 } Implementation detail: For every b you see, cross off one of the c s ( z ): Until all b s have been crossed off ( y ) Replace current b by y Move right until you see first c Cross off c ( z ) Move left until first b Restore the b s: Replace all y s by b s

42 Programming tools move left until you see a move left until you pass all z s

43 Looping behavior Something strange can happen in a Turing Machine: Inputs can be divided into three types q0q0 q acc q rej  = {0, 1} input:  ☐/☐R☐/☐R 0/0R 1/1R This machine never halts q acc q rej accept rejectloop forever

44 The Church-Turing Thesis Turing Machine quantum computing DNA computing cosmic computing

45 The Church-Turing Thesis “On Computable Numbers, with an Application to the Entscheidungsproblem” 1936: Section 9. The extent of the computable numbers All arguments [for the CT Thesis] which can be given are bound to be, fundamentally, appeals to intuition, and for this reason rather unsatisfactory mathematically. The arguments which I shall use are of three kinds: 1. A direct appeal to intuition 2. A proof of the equivalence of two definitions (In case the new definition has greater intuitive appeal) 3. Giving examples of large classes of numbers which are computable.


Download ppt "CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Turing Machines."

Similar presentations


Ads by Google