Presentation is loading. Please wait.

Presentation is loading. Please wait.

Instructor: Aaron Roth

Similar presentations


Presentation on theme: "Instructor: Aaron Roth"— Presentation transcript:

1 Instructor: Aaron Roth aaroth@cis.upenn.edu
CIS 262 Automata, Computability, and Complexity Spring Instructor: Aaron Roth Lecture: March 11, 2019

2 Recap: Turing machines: Syntax
A TM M consists of A finite set Q of states Initial state q0 (belongs to Q) Accepting state qa (belongs to Q) Rejecting state qr (belongs to Q and different from qa) Tape alphabet G Input alphabet S (a subset of G) Blank symbol _ (belongs to G \ S) Transition function d : Q x G  Q x G x {L, R} d(q, s) = (q’, g, L/R) means that in state q, if current tape cell contains s, then write g, move left/right, and goto state q’

3 Recap: Turing Machines: Semantics
Consider TM M = (Q, q0, qa, qr, G, S, _, d ) Configuration C = (u, q, v) such that u, v are strings over G and q in Q Accepting configuration: q = qa Rejecting configuration: q = qr, or u = e and transition says move left Halting configuration: Accepting/rejecting configuration One-step execution semantics: for non-halting configuration C, Next(C) is the configuration resulting from executing one transition of M Execution of M on input w is the unique sequence of configurations C0, C1, C2, … such that 1. C0 = (e, q0 , w ) is the initial configuration 2. For each i, Ci+1 = Next ( Ci ) 3. Either sequence is infinite, or Ck is halting configuration L(M) = {w | Execution of M on w is finite ending in accepting configuration}

4 Halting Turing Machines
A Turing machine M is said to be halting if for every input w, the execution of M on w is finite/terminating Halting TM == Programs that are guaranteed not to enter infinite loops Machine from last class for palindromes is a halting TM

5 Decidable Languages A language L is called “decidable” if there exists a halting Turing machine M such that L(M) = L that is, there is a TM M that given an input w, if w is in L, halts in the accepting state and otherwise, halts in the rejecting state Decidable language == Solvable problem Example: PALINDROMES = { w | w is a palindrome } is decidable

6 Every Regular Language is Decidable
A language L is regular if there is a DFA M such that L(M) = L Clearly, a TM can do what a DFA can, and also guarantee halting More precisely, suppose M = (Q, S, q0, F, d) Corresponding halting TM M’: keep moving right over input updating state as M does upon _, i.e. end of input, accept or reject based on whether state is in F States = Q U {qa, qr } G = S U { _ } d’(q, s) = (d(q, s), s, R) d’(q, _ ) equals qa if q is in F and qr otherwise

7 Checking Primality PRIMES = { 0p | p is a prime number } Clearly there is a terminating program that checks whether the length is a prime number, so PRIMES must be decidable But let’s build a halting TM M

8 Checking Primality PRIMES = { 0p | p is a prime number } High-level algorithm: if p=0 or p=1, then accept else { i = 2; while (i < p) { if p is a multiple of i, then stop and reject; i = i+1; }; accept }

9 TM for PRIMES … _ _ _ _ First check if input is e or 0, accept if so If not, add # at the beginning, and replace first two 0’s by 1’s # … _ _ Given input # 1i 0j, (note: original p equals i+j) if j = 0, then p is a prime, accept else if j is a multiple of i, then p is not a prime, reject else replace first 0 by 1 (that is, increment i) and repeat

10 TM for PRIMES # … _ _ Given input # 1i 0j, with i>=2 and j!=0, check if j is a multiple of i High-level algorithm: Repeatedly subtract i from j till it becomes 0 Intermediate tape contents: # 1i 2a 0b , where a+b=j Initially: a=0 and b=j Repeat{ if (b=0) then stop, j is a multiple of i else if (b < i) then stop, j is not a multiple of i else { a = a+i; b = b-i } } Change 0 to 2 for each 1

11 TM for PRIMES # … … _ _ s0 Given input # 1i 0j, with i>=2 and j!=0, check if j is a multiple of i Assume head is pointing to first 1 in state s0 Cross off 1 with x 1/x,R s0 s1

12 TM for PRIMES # x 1 … 1 0 … 0 _ _ Move right searching for 0
1/x,R If 0 found, replace it with 2 s0 s1 0/2,L x/R s2 And keep moving left till first 1 1, 2/ L

13 TM for PRIMES # x x … … … _ _ s1 What if no 0 found in state s1? 1, 2/ R 1/x,R b (i.e. left over j) < i Conclude j is not a multiple of i s0 s1 _ / L 0/2,L x/R s3 s2 1, 2/ L

14 TM for PRIMES # x x … x 2 … 2 0 … 0 _ _
What if no 1 left in state s0 ? 1, 2/ R 1/x,R i has been subtracted from j: if more 0’s left, subtract again else j is a multiple of i s0 s1 _ / L 2/R 0/2,L x/R s3 2/R s4 s2 _ 1, 2/ L 0/L s5 qr

15 TM for PRIMES # x x … x 2 … 2 0 … 0 _ _ From state s5 go back left to
1/x,R s0 s1 _ / L 2/R 0/2,L x/R # / R s3 2/R s4 s2 _ 1, 2/ L 0/L s5 From state s5 go back left to subtract again in state s0 but make sure to restore i by changing x’s back to 1’s qr 2 /L x / 1, L

16 TM for PRIMES # x x … 1 2 … 2 … 2 _ _ State s3 :
1/x,R s0 s1 _ / L 2/R 0/2,L x/R 1,x/R 0/1,L # / R s3 s6 s7 2/R s4 s2 _ 0,1 /L x / 1, L 2/0, L 1, 2/ L 0/L s5 qr 2 /L x / 1, L State s3 : j is not a multiple of i clean-up: change 2’s to 0’s and x’s to 1’s increment i (change one 0 to 1)

17 TM for PRIMES # 1 … 1 0 … 0 _ _ State s7 :
0,1/ L # 1 … … 0 _ _ s9 0 / L s7 # / R 1, 2/ R s8 1/R 1/x,R s0 s1 # / R _ / L 2/R 0/2,L 0/1,L x/R 1,x/R # / R s3 s6 s7 2/R s4 s2 _ 0,1 /L x / 1, L 2/0, L 1, 2/ L 0/L s5 qr 2 /L x / 1, L State s7 : if # encountered, should we go back to s0 ? only after checking j != 0 (i.e. there is a 0)

18 TM for PRIMES # 1 … 1 _ _ State s8 : if _ encountered,
0,1 / L # 1 … _ _ s9 qa 0 / L s8 # / R _ 1, 2/ R s8 1/R 1/x,R s0 s1 # / R _ / L 2/R 0/2,L 0/1,L x/R 1,x/R # / R s3 s6 s7 2/R s4 s2 _ 0,1 /L x / 1, L 2/0, L 1, 2/ L 0/L s5 qr 2 /L x / 1, L State s8 : if _ encountered, j=0, i has reached p, p must be a prime

19 Completing the machine
_ s9 qa q0 0 / L _ 0/#,R # / R _ 1, 2/ R s8 1/R q1 0/1,R 1/x,R s0 s1 # / R q2 _ / L _ /1,L 2/R 0/2,L 0/1,L 0/1,R x/R 1,x/R # / R s3 s6 s7 q3 2/R s4 s2 _ /0,L _ 0, 1 /L x / 1, L 2/0, L 0, R 1, 2/ L 0/L s5 qr 2 /L x / 1, L Initially, if input is e or 0, accept, else insert # at the beginning, and replace first two 0’s by 1’s

20 TM for PRIMES This TM M is a halting TM
_ s9 qa q0 0 / L _ 0/#,R # / R _ 1, 2/ R s8 1/R q1 0/1,R 1/x,R s0 s1 # / R q2 _ / L _ /1,L 2/R 0/2,L 0/1,L 0/1,R x/R 1,x/R # / R s3 s6 s7 q3 2/R s4 s2 _ /0,L _ 0, 1 /L x / 1, L 2/0, L 0, R 1, 2/ L 0/L s5 qr 2 /L x / 1, L This TM M is a halting TM L(M) = PRIMES = { 0p | p is a prime }

21 Exercise: Checking Primality
PRIMES = { 0p | p is a prime number } if p=0 or p=1, then accept else { i = 2; while (i < p) { if p is a multiple of i, then stop and reject; i = i+1; }; accept } If p is not a multiple of i, then we should cross off all i’ such that i’ < p and i’ is a multiple of i There is no need to check if p is a multiple of such i’ Modify the TM we just constructed to implement this optimization

22 Decidable Languages A language L is called “decidable” if there exists a halting Turing machine M such that L(M) = L Examples: PALINDROMES = { w | w is a palindrome } is decidable PRIMES All regular languages { w | count(w, a) = count(w, b) } … All problems that can be solved by correct, terminating programs

23 Beyond Decidable Languages
Consider TM M L(M) = { w | M halts on w in its accepting state } A language L is called “recognizable” or equivalently, “recursively enumerable” (RE), if there exists a TM M such that L(M) = L Weaker notion than decidable languages: L is decidable implies that L is recognizable, but not conversely

24 Hilbert’s 10th problem Given a multi-variable polynomial with integer coefficients, are there integer values for the variables that make the polynomial 0 ? Input: x2 – 1 Answer: Yes Input: x2 + 1 Answer: No Input: x2y –yz3 +367xyz Answer: ?? Hilbert’s challenge (1900): Find a systematic procedure (i.e. an algorithm) for this problem

25 Hilbert’s 10th problem Given a multi-variable polynomial p(x1, x2, … xn) with integer coefficients, are there integer values for the variables that make the polynomial 0? Plausible strategy: Systematically try out all integer combinations of the values for the n variables, and for each combination, evaluate p, and stop saying YES if the result is 0 Challenge: when should we stop and conclude that there are no integer roots ?

26 Hilbert’s 10th problem HILBERT10 = {p(x1, x2, … xn) | there exist integers c1, c2, … cn such that p(c1, c2, … cn) = 0 } Program P to “solve” HILBERT10: k = 0; repeat { for all integer vectors [c1, c2, … cn] with –k <= ci <= +k, for each i, if p(c1, c2, … cn) = 0, then STOP and ACCEPT; k = k + 1 } Claim: if input polynomial belongs to HILBERT10, then P stops and accepts L(P) = HILBERT10 Using same idea, one can build a TM M such that L(M) = HILBERT10

27 Recognizable Languages
There is a TM that accepts HILBERT10, though it is not a halting TM (and in fact, if input polynomial does not have integer roots, our machine will loop forever) This means that HILBERT10 is a recognizable language Is HILBERT10 a decidable language ? The fact that our solution was not a halting TM does not imply anything But… in 1970, Matiyasevich proved that HILBERT10 is undecidable ! there is no halting TM to solve this problem

28 Recognizable Languages
L is recognizable intuitively means that it is possible to design a program/TM M such that M can systematically check if input meets the requirement of L but has no scheme for checking the negation M gives only correct answers, but may not terminate when input is not in L Why study this class? There are many interesting problems that are recognizable but not decidable Furthermore, there are many problems that are not even recognizable!

29 Problem Classification
REGULAR DECIDABLE HILBERT10 a*b PRIMES RECOGNIZABLE ALL LANGUAGES


Download ppt "Instructor: Aaron Roth"

Similar presentations


Ads by Google