Decidability Gian Diego Tipaldi Topics Covered Investigation on - - PowerPoint PPT Presentation

โ–ถ
decidability
SMART_READER_LITE
LIVE PREVIEW

Decidability Gian Diego Tipaldi Topics Covered Investigation on - - PowerPoint PPT Presentation

Theoretical Computer Science (Bridging Course) Decidability Gian Diego Tipaldi Topics Covered Investigation on what is solvable Decidable languages The halting problem Decidable Problems Acceptance problem: Decide if a


slide-1
SLIDE 1

Theoretical Computer Science (Bridging Course)

Gian Diego Tipaldi

Decidability

slide-2
SLIDE 2

Topics Covered

  • Investigation on what is solvable
  • Decidable languages
  • The halting problem
slide-3
SLIDE 3

Decidable Problems

  • Acceptance problem:
  • Decide if a string is accepted
  • Equivalence problem:
  • Decide if two automata are equivalent
  • Emptiness test problem:
  • Decide if the accepted language is empty
  • Applied to DFA,NFA,RE,PDA,CFG,TM,โ€ฆ
slide-4
SLIDE 4

Acceptance problem for DFAs

  • Decide is a DFA accept a string w
  • Express it as a language ๐ต๐ธ๐บ๐ต

๐ต๐ธ๐บ๐ต = ๐ถ, ๐‘ฅ ๐ถ is a DFA that accepts ๐‘ฅ

  • B is the encoding of a DFA
  • Testing acceptance is equivalent to

language membership

slide-5
SLIDE 5

Acceptance problem for DFAs

q0 q1 q2 q3 # 1 # <table> โ€ฆ # q0 # q2 q3 # # 1 1 1 1 1 # q0

  • Use a decider to test membership
  • Idea: Decider will simulate B and

accept/reject if B accepts/rejects w

  • Encoding of B = (๐‘…, ฮฃ, ๐œ€, ๐‘Ÿ๐‘, ๐บ) and w
slide-6
SLIDE 6

Acceptance problem for DFAs

q0 q1 q2 q3 # 1 # <table> โ€ฆ # q0 # q2 q3 # # 1 1 1 1 1 # q0

  • Use a decider to test membership
  • Idea: Decider will simulate B and

accept/reject if B accepts/rejects w

  • Encoding of B = (๐‘…, ฮฃ, ๐œ€, ๐‘Ÿ๐‘, ๐บ) and w
slide-7
SLIDE 7

Acceptance problem for DFAs

q0 q1 q2 q3 # 1 # <table> โ€ฆ # q0 # q2 q3 # # 1 1 1 1 1 # q0

  • Use a decider to test membership
  • Idea: Decider will simulate B and

accept/reject if B accepts/rejects w

  • Encoding of B = (๐‘…, ฮฃ, ๐œ€, ๐‘Ÿ๐‘, ๐บ) and w
slide-8
SLIDE 8

Acceptance problem for DFAs

q0 q1 q2 q3 # 1 # <table> โ€ฆ # q0 # q2 q3 # # 1 1 1 1 1 # q0

  • Use a decider to test membership
  • Idea: Decider will simulate B and

accept/reject if B accepts/rejects w

  • Encoding of B = (๐‘…, ฮฃ, ๐œ€, ๐‘Ÿ๐‘, ๐บ) and w
slide-9
SLIDE 9

Acceptance problem for DFAs

q0 q1 q2 q3 # 1 # <table> โ€ฆ # q0 # q2 q3 # # 1 1 1 1 1 # q0

  • Use a decider to test membership
  • Idea: Decider will simulate B and

accept/reject if B accepts/rejects w

  • Encoding of B = (๐‘…, ฮฃ, ๐œ€, ๐‘Ÿ๐‘, ๐บ) and w
slide-10
SLIDE 10
  • Use a decider to test membership
  • Idea: Decider will simulate B and

accept/reject if B accepts/rejects w

  • Encoding of B = (๐‘…, ฮฃ, ๐œ€, ๐‘Ÿ๐‘, ๐บ) and w

Acceptance problem for DFAs

q0 q1 q2 q3 # 1 # <table> โ€ฆ # q0 # q2 q3 # # 1 1 1 1 1 # q0

slide-11
SLIDE 11

Acceptance problem for DFAs

  • Use a decider to test membership
  • Idea: Decider will simulate B and

accept/reject if B accepts/rejects w

  • Encoding of B = (๐‘…, ฮฃ, ๐œ€, ๐‘Ÿ๐‘, ๐บ) and w

q0 q1 q2 q3 # 1 # <table> โ€ฆ # q0 # q2 q3 # # 1 1 1 1 1 # q0

slide-12
SLIDE 12

Acceptance problem for DFAs

q0 q1 q2 q3 # 1 # <table> โ€ฆ # q0 # q2 q3 # # 1 1 1 1 1 # q0

  • Use a decider to test membership
  • Idea: Decider will simulate B and

accept/reject if B accepts/rejects w

  • Encoding of B = (๐‘…, ฮฃ, ๐œ€, ๐‘Ÿ๐‘, ๐บ) and w
slide-13
SLIDE 13

Acceptance problem for DFAs

Theorem 4.1: ๐ต๐ธ๐บ๐ต is a decidable language. Proof: M= โ€œOn input ๐ถ, ๐‘ฅ , where ๐ถ is a DFA and ๐‘ฅ is a string:

1.Simulate ๐ถ on input ๐‘ฅ. 2.If the simulation ends in an accept state,

  • accept. If it ends in a nonaccepting state,

reject.โ€

slide-14
SLIDE 14

Acceptance problem for NFAs

Theorem 4.2: ๐ต๐‘‚๐บ๐ต is a decidable language. Proof: N = โ€œOn input ๐ถ, ๐‘ฅ , where ๐ถ is a NFA and ๐‘ฅ is a string:

1.Convert the NFA in an equivalent DFA ๐ท 2.Run the previous machine on input โŒฉ๐ท, ๐‘ฅโŒช 3.If the simulation ends in an accept state,

  • accept. If it ends in a nonaccepting state,

reject.โ€

slide-15
SLIDE 15

Acceptance problem for REs

Theorem 4.3: ๐ต๐‘†๐น is a decidable language. Proof: P = โ€œOn input ๐ถ, ๐‘ฅ , where ๐ถ is a RE and ๐‘ฅ is a string:

1.Convert the RE in an equivalent NFA ๐ต 2.Run the machine N on input โŒฉ๐ต, ๐‘ฅโŒช 3.If N accepts, accept. If N rejects, reject.โ€

slide-16
SLIDE 16

Emptiness problem for DFAs

  • Decide is a DFA accept the empty

language

  • Express it as a language ๐น๐ธ๐บ๐ต

๐น๐ธ๐บ๐ต = ๐ต ๐ต is a DFA for which ๐‘€ ๐ต = โˆ…

  • A is the encoding of a DFA
slide-17
SLIDE 17

Emptiness problem for DFAs

Theorem 4.4: ๐น๐ธ๐บ๐ต is a decidable language. Proof idea: A DFA accepts some string iff it is possible to reach an accept state using valid transitions. Construct a TM T similar to the one for connected graphs

slide-18
SLIDE 18

Emptiness problem for DFAs

Theorem 4.4: ๐น๐ธ๐บ๐ต is a decidable language. Proof: T = โ€œOn input ๐ต , where ๐ต is a DFA:

1.Mark the start state of ๐ต 2.Repeat until no new state is marked

1.Mark a state if it has a transition to it coming from any other marked state

3.If no accept state is marked, accept. Otherwise, reject.โ€

slide-19
SLIDE 19

Equivalence Problem for DFAs

Theorem 4.5: ๐น๐‘…๐ธ๐บ๐ต = ๐ต, ๐ถ ๐ต, ๐ถ โˆˆ DFA, ๐‘€ ๐ต = ๐‘€ ๐ถ is a decidable language. Proof idea: Prove the symmetric difference is empty. ๐‘€ ๐ท = ๐‘€ ๐ถ โˆฉ ๐‘€ ๐ต โˆช ๐‘€ ๐ต โˆฉ ๐‘€ ๐ถ

The symmetric difference of L(A) and L(B) L(B) L(A)

slide-20
SLIDE 20

Equivalence Problem for DFAs

Theorem 4.5: ๐น๐‘…๐ธ๐บ๐ต is a decidable language. Proof: F = โ€œOn input ๐ต, ๐ถ , where ๐ต, ๐ถ are DFA:

1.Construct the DFA ๐ท for the symmetric difference language (closure property) 2.Run TM T from Theorem 4.4 3.If T accepts, accept. If T rejects, reject.โ€

slide-21
SLIDE 21

Acceptance Problem for CFGs

Theorem 4.7: ๐ต๐ท๐บ๐ป = ๐ป, ๐‘ฅ ๐ป is a CFG that generates ๐‘ฅ is a decidable language. Proof idea: Rely on the fact that if G is in CNF, then any derivation of w has length at most 2|w| + 1. Also consider that there are only finitely many derivations of length less than n.

slide-22
SLIDE 22

Acceptance Problem for CFGs

Theorem 4.7: ๐ต๐ท๐บ๐ป is a decidable language. Proof: S = โ€œOn input ๐ป, ๐‘ฅ , where ๐ถ is a CFG and ๐‘ฅ is a string:

1.Convert G to a CNF 2.List all derivations with k=2n-1 steps, n is the length of w. if n=0 consider k=1. 3.If any of them generates w, accept. If not, reject.โ€

slide-23
SLIDE 23

Emptiness Problem for CFGs

Theorem 4.7: ๐น๐ท๐บ๐ป = ๐ป ๐ป is a CFG for which ๐‘€ ๐ป = โˆ… is a decidable language. Proof idea: Determine for each variable whether that variable is capable to generate a string of terminals

slide-24
SLIDE 24

Emptiness Problem for CFGs

Theorem 4.7: ๐น๐ท๐บ๐ป is a decidable language. Proof: R = โ€œOn input ๐ป , where ๐ป is a CFG:

1.Mark all terminal symbols in G 2.Repeat until no new variable is marked

1.Mark any variable A if G contains ๐ต โ†’ ๐‘‰1 โ€ฆ ๐‘‰๐‘™ and ๐‘‰1, โ€ฆ , ๐‘‰๐‘™ have all been marked

3.If the start symbol is marked, accept. If not, reject.โ€

slide-25
SLIDE 25

Equivalence Problem for CFGs

๐น๐‘…๐ท๐บ๐ป = ๐ป, ๐ผ ๐ป, ๐ผ โˆˆ ๐ท๐บ๐ป๐‘ก, ๐‘€ ๐ป = ๐‘€ ๐ผ

  • Is it decidable?
slide-26
SLIDE 26

Equivalence Problem for CFGs

๐น๐‘…๐ท๐บ๐ป = ๐ป, ๐ผ ๐ป, ๐ผ โˆˆ ๐ท๐บ๐ป๐‘ก, ๐‘€ ๐ป = ๐‘€ ๐ผ

  • Is it decidable? NO!
  • We cannot use the same method as

for DFAs, since context free languages are not closed under complementation nor intersection.

slide-27
SLIDE 27

Decidability of CFLs

Theorem 4.9: Every context free language is decidable. Proof: Let G be a CFG for the language ๐‘๐ป = โ€œOn input ๐‘ฅ:

1.Run the TM S on input ๐ป, ๐‘ฅ 2.If S accepts, accept; If S rejects, reject.โ€

slide-28
SLIDE 28

Classes of Languages

slide-29
SLIDE 29

Classes of Languages

slide-30
SLIDE 30

Classes of Languages

slide-31
SLIDE 31

Classes of Languages

slide-32
SLIDE 32

The Halting Problem

  • Some problems are unsolvable
  • Famous example: the halting problem

Philosophical implication: Computers are fundamentally limited

slide-33
SLIDE 33

The Halting Problem

๐ต๐‘ˆ๐‘ = ๐‘, ๐‘ฅ ๐‘ is a TM that accepts ๐‘ฅ Theorem 4.11: ๐ต๐‘ˆ๐‘ is undecidable Observation: ๐ต๐‘ˆ๐‘ is Turing recognizable, thus recognizer are more powerful than deciders.

slide-34
SLIDE 34

The Halting Problem

๐ต๐‘ˆ๐‘ = ๐‘, ๐‘ฅ ๐‘ is a TM that accepts ๐‘ฅ The following machine recognizes it U = โ€œOn input ๐‘, ๐‘ฅ , where M is a TM and w is a string

  • 1. Simulate M on input w
  • 2. If M ever enters the accept state,

accept; if M ever enters the reject state, reject.โ€

slide-35
SLIDE 35

Diagonalization

  • Developed by G. Cantor in 1873
  • Concerns the measure of infinite sets
  • Used to prove the halting problem
  • Do sets A and B have the same size?
  • If finite, one can count the elements
  • How about infinite sets?
slide-36
SLIDE 36

Diagonalization

  • Consider possible pairings from A to B
  • Consider the function ๐‘”: ๐ต โ†’ ๐ถ
  • f is injective: ๐‘” ๐‘ โ‰  ๐‘” ๐‘ , whenever ๐‘ โ‰  ๐‘
  • f is surjective: โˆ€ ๐‘ โˆˆ ๐ถ, โˆƒ๐‘ โˆˆ ๐ต: ๐‘” ๐‘ = ๐‘
  • f is bijective if injective and surjective
  • A and B have same size if โˆƒ ๐‘” bijective
  • A set is countable if size at most of โ„•
slide-37
SLIDE 37

Example โ€“ Even Numbers

  • Consider this two sets

๐ต = ๐‘ ๐‘ โˆˆ โ„• , ๐ถ = ๐‘ ๐‘ 2 โˆˆ โ„•

  • Consider the function ๐‘”: ๐ต โ†’ ๐ถ

๐‘” ๐‘œ = 2๐‘œ

  • f is a bijective function, therefore A

and B have the same size and B is countable

slide-38
SLIDE 38

Example โ€“ Rational Numbers

  • Consider the set of rational numbers

โ„š = ๐‘› ๐‘œ | ๐‘›, ๐‘œ โˆˆ โ„•

  • โ„š seems much larger than โ„•
slide-39
SLIDE 39

Example โ€“ Rational Numbers

  • Consider the set of rational numbers

โ„š = ๐‘› ๐‘œ | ๐‘›, ๐‘œ โˆˆ โ„•

  • โ„š seems much larger than โ„•, butโ€ฆ
  • โ„š is countable
slide-40
SLIDE 40

Example โ€“ Rational Numbers

slide-41
SLIDE 41

Example โ€“ Real Numbers

  • Consider the set of real numbers โ„
  • ๐œŒ = 3.1415926 โ€ฆ
  • 2 = 1.4142135 โ€ฆ
  • Is it countable?
slide-42
SLIDE 42

Example โ€“ Real Numbers

Theorem 4.17: โ„ is uncountable Proof (by contradiction): Assume that there is an f from โ„• to โ„. Find an ๐‘ฆ in โ„ that ๐‘ฆ โ‰  ๐‘” ๐‘œ โˆ€ ๐‘œ โˆˆ โ„•. x is a number between 0 and 1. The first digit is different than the first decimal of f(1), the second is different than the second decimal of f(2) and so onโ€ฆ

slide-43
SLIDE 43

Example โ€“ Real Numbers

Theorem 4.17: โ„ is uncountable Proof (by contradiction): n f(n) 1 3.1414โ€ฆ 2 5.567โ€ฆ 3 0.888888โ€ฆ โ€ฆ โ€ฆ

slide-44
SLIDE 44

Example โ€“ Real Numbers

Theorem 4.17: โ„ is uncountable Proof (by contradiction): n f(n) 1 3.1414โ€ฆ 2 5.567โ€ฆ 3 0.888888โ€ฆ โ€ฆ โ€ฆ x = 0.275โ€ฆ

slide-45
SLIDE 45

Example โ€“ Real Numbers

Theorem 4.17: โ„ is uncountable Proof (by contradiction): n f(n) 1 3.1414โ€ฆ 2 5.567โ€ฆ 3 0.888888โ€ฆ โ€ฆ โ€ฆ x = 0.275โ€ฆ So, x โ‰  f(n) for all n

slide-46
SLIDE 46

What About Turing Machines?

  • The set of all strings ฮฃโˆ— is countable
  • Similar to rational numbers
  • Go from small strings to bigger
  • We can encode a TM as a string
  • The set of TM is countable
slide-47
SLIDE 47

Uncountable Languages

Lemma: The set B of infinite binary strings is uncountable Proof: Proceed as with the real numbers. Find an infinite string whose first symbol is different than the first symbol on the first string and so onโ€ฆ

slide-48
SLIDE 48

Uncountable Languages

Lemma: The set L of all languages is uncountable Proof: Define a correspondence between L and

  • B. Take the set of all strings ฮฃโˆ— . Encode

a language A with a binary string ๐œ“๐ต, where 1 means a string belongs to A.

slide-49
SLIDE 49

Turing Recognizable Languages

Theorem 4.18: Some languages are not Turing recognizable Proof: The set of TMs is countable, while the set of all language is not. Therefore, there is no correspondence between the set of languages and the set of TMs.

slide-50
SLIDE 50

The Halting Problem

๐ต๐‘ˆ๐‘ = ๐‘, ๐‘ฅ ๐‘ is a TM that accepts ๐‘ฅ Theorem 4.11: ๐ต๐‘ˆ๐‘ is undecidable Proof (by contradiction): Assume ๐ต๐‘ˆ๐‘ is decidable and H is a decider for that. Build another decider D that contradicts the hypothesis. Hint: Use H to define D.

slide-51
SLIDE 51

The Halting Problem

Proof (by contradiction): D = โ€œOn input โŒฉ๐‘โŒช, where M is a TM:

  • 1. Run H on โŒฉ๐‘, ๐‘ โŒช
  • 2. Accept if H rejects and vice versaโ€

We have

slide-52
SLIDE 52

The Halting Problem

Proof (by contradiction): D = โ€œOn input โŒฉ๐‘โŒช, where M is a TM:

  • 1. Run H on โŒฉ๐‘, ๐‘ โŒช
  • 2. Accept if H rejects and vice versaโ€

We have (on its own encoding)

slide-53
SLIDE 53

The Halting Problem

Proof (by contradiction): D = โ€œOn input โŒฉ๐‘โŒช, where M is a TM:

  • 1. Run H on โŒฉ๐‘, ๐‘ โŒช
  • 2. Accept if H rejects and vice versaโ€

We have (on its own encoding)

slide-54
SLIDE 54

The Halting Problem

Where is the diagonalization?

slide-55
SLIDE 55

The Halting Problem

Where is the diagonalization?

<M1> <M2> <M3> <M4> ... <D> ... M1 accept accept accept M2 accept accept accept accept accept M3 ... ... M4 accept accept accept โ‹ฎ โ‹ฎ โ‹ฑ

slide-56
SLIDE 56

The Halting Problem

Where is the diagonalization?

<M1> <M2> <M3> <M4> ... <D> ... M1 accept reject accept reject accept M2 accept accept accept accept accept M3 reject reject reject reject ... reject ... M4 accept reject accept reject accept โ‹ฎ โ‹ฎ โ‹ฑ

slide-57
SLIDE 57

The Halting Problem

Where is the diagonalization?

<M1> <M2> <M3> <M4> ... <D> ... M1 accept reject accept reject accept M2 accept accept accept accept accept M3 reject reject reject reject ... reject ... M4 accept reject accept reject accept โ‹ฎ โ‹ฎ โ‹ฑ

slide-58
SLIDE 58

The Halting Problem

Where is the diagonalization?

<M1> <M2> <M3> <M4> ... <D> ... M1 accept reject accept reject accept M2 accept accept accept accept accept M3 reject reject reject reject ... reject ... M4 accept reject accept reject accept โ‹ฎ โ‹ฎ โ‹ฑ D reject reject accept accept ? โ‹ฎ โ‹ฎ โ‹ฑ

slide-59
SLIDE 59

Non Recognizable Languages

  • Are there languages that are not even

Turing recognizable?

slide-60
SLIDE 60

Non Recognizable Languages

  • Are there languages that are not even

Turing recognizable?

  • Yes!
  • We need something harder than ๐ต๐‘ˆ๐‘
slide-61
SLIDE 61

Co-Turing Recognizable

A language is co-Turing recognizable if it is the complement of a Turing recognizable language Theorem 4.22: A language is decidable iff it is Turing recognizable and co-Turing recognizable

slide-62
SLIDE 62

Co-Turing Recognizable

Theorem 4.22: A language is decidable iff it is Turing recognizable and co-Turing recognizable Proof (forward): If A is decidable, then the complement

  • f A is decidable. A decidable language

is also Turing recognizable.

slide-63
SLIDE 63

Co-Turing Recognizable

Theorem 4.22: A language is decidable iff it is Turing recognizable and co-Turing recognizable Proof (backward): M1,M2 are the recognizer of A, co-A. M = โ€œOn input w:

  • 1. Run M1 and M2 in parallel.
  • 2. If M1 accepts, accept. If M2 accepts,

rejectโ€

slide-64
SLIDE 64

Non Recognizable Languages

Corollary: ๐ต๐‘ˆ๐‘ is not Turing recognizable Proof: We know that ๐ต๐‘ˆ๐‘ is Turing recognizable. Assume ๐ต๐‘ˆ๐‘ is also Turing recognizable. Then ๐ต๐‘ˆ๐‘ would be decidable. Contradiction: Theorem 4.11 tells us not!

slide-65
SLIDE 65

Example Exam Question

slide-66
SLIDE 66

Classes of Languages

slide-67
SLIDE 67

Classes of Languages

๐ต๐ธ๐บ๐ต, ๐ต๐‘‚๐บ๐ต, ๐ต๐‘†๐น,

๐ต๐ท๐บ๐ป, ๐น๐ธ๐บ๐ต, ๐น๐ท๐บ๐ป, ๐น๐‘…๐ธ๐บ๐ต

slide-68
SLIDE 68

Classes of Languages

๐ต๐ธ๐บ๐ต, ๐ต๐‘‚๐บ๐ต, ๐ต๐‘†๐น,

๐ต๐ท๐บ๐ป, ๐น๐ธ๐บ๐ต, ๐น๐ท๐บ๐ป, ๐น๐‘…๐ธ๐บ๐ต ๐ต๐‘ˆ๐‘

slide-69
SLIDE 69

Classes of Languages

๐ต๐ธ๐บ๐ต, ๐ต๐‘‚๐บ๐ต, ๐ต๐‘†๐น,

๐ต๐ท๐บ๐ป, ๐น๐ธ๐บ๐ต, ๐น๐ท๐บ๐ป, ๐น๐‘…๐ธ๐บ๐ต ๐ต๐‘ˆ๐‘ ๐ต๐‘ˆ๐‘

slide-70
SLIDE 70

Summary

  • Decidable problems
  • Acceptance
  • Emptiness test
  • Equivalence
  • The halting problem
  • Digaonalization