CSE 105 THEORY OF COMPUTATION Fall 2016 - - PowerPoint PPT Presentation

cse 105
SMART_READER_LITE
LIVE PREVIEW

CSE 105 THEORY OF COMPUTATION Fall 2016 - - PowerPoint PPT Presentation

CSE 105 THEORY OF COMPUTATION Fall 2016 http://cseweb.ucsd.edu/classes/fa16/cse105-abc/ Language of a TM L(M) = {w | M accepts w} M may reject or loop on strings not in L(M) A language X is recognizable if X=L(M) for some TM M A


slide-1
SLIDE 1

CSE 105

THEORY OF COMPUTATION

Fall 2016 http://cseweb.ucsd.edu/classes/fa16/cse105-abc/

slide-2
SLIDE 2

Language of a TM

  • L(M) = {w | M accepts w}
  • M may reject or loop on strings not in L(M)
  • A language X is recognizable if X=L(M) for some TM M
  • A TM M is a decider if M(w) halts on every input w
  • A language X is decidable is X=L(M) for some decider M
slide-3
SLIDE 3

Summary

  • Theorem: A language L is decidable if and only if it is

both recognizable and co-recognizable: D = RE ∩ coRE

RE co-RE Context-free Regular Decidable

slide-4
SLIDE 4

Closure properties (D)

  • Decidable languages are closed under

Union

Intersection

Set Complement

Set Difference

….

  • Proof: similar to the proof for union
slide-5
SLIDE 5

Closure properties (D)

  • Theorem: If A and B are decidable, then AUB is decidable
  • Proof:

Let M, M’ be deciders such that L(M)=A, L(M’)=B

We build a decider for AUB, M’’(w) =

1) Run M(w). If M(w) accepts, then accept 2) Run M’(w). If M’(w) accepts, then accept 3) Otherwise, reject

slide-6
SLIDE 6

Closure properties for RE

  • Theorem: If A and B are in RE, then AUB is also in RE
  • Proof:

Let M, M’ be TMs such that L(M)=A, L(M’)=B

We need to build a TM such that L(M’’)=AUB. M’’(w) =

1) Run M(w). If M(w) accepts, then accept 2) Run M’(w). If M’(w) accepts, then accept 3) Otherwise, reject

slide-7
SLIDE 7

Closure properties

  • Theorem: If A and B are recognizable, then AUB is

recognizable

  • Proof:

Let M, M’ be TMs such that L(M)=A, L(M’)=B

We build a TM for AUB, M’’(w) =

1) Run M(w). If M(w) accepts, then accept 2) Run M’(w). If M’(w) accepts, then accept 3) Otherwise, reject

Question: Is M’’ a decider? A) Yes, because it always terminate B) No, beause it may loop in step 1 C) No, because it may loop in step 2 D) I can’t decide, I am not a decider

slide-8
SLIDE 8

Closure properties

  • Theorem: If A and B are recognizable, then AUB is

recognizable

  • Proof:

Let M, M’ be TMs such that L(M)=A, L(M’)=B

We build a TM for AUB, M’’(w) =

1) Run M(w). If M(w) accepts, then accept 2) Run M’(w). If M’(w) accepts, then accept 3) Otherwise, reject

Question: What property best describes the language of M’’? A) L(M’’) = A U B B) A ⊆ L(M’’) ⊆ AUB C) A∩B ⊆ L(M’’) ⊆ A U B D) L(M’’) = A – B E) None of the above

slide-9
SLIDE 9

Closure Properties (RE)

  • Can we fix the proof, and show that RE is closed under

union?

  • Is RE closed under

Union?

Intersection?

Complement?

Set Difference?

slide-10
SLIDE 10

Closure of RE under union

  • Theorem: If A and B are recognizable, then AUB is

recognizable

  • Proof:

Let M, M’ be TMs such that L(M)=A, L(M’)=B

We build a TM for AUB, M’’(w) =

  • 1. For t=1,2,3,….

1) Run M(w) for t steps. If M(w) accepts, then accept 2) Run M’(w) for t steps. If M’(w) accepts, then accept 3) Otherwise, continue to next t

slide-11
SLIDE 11

Closure of RE under union

  • Theorem: If A and B are recognizable, then AUB is

recognizable

  • Proof:

Let M, M’ be TMs such that L(M)=A, L(M’)=B

We build a TM for AUB, M’’(w) =

  • 1. For t=1,2,3,….

1) Run M(w) for t steps. If M(w) accepts, then accept 2) Run M’(w) for t steps. If M’(w) accepts, then accept 3) Otherwise, continue to next t

Question: Is M’’ a decider? A) Yes, it always terminate B) No, beause it may loop in step 1 C) No, because it may loop in step 2 D) No, because of infinite loop “for t=1,2,3 ...” E) I don’t know

slide-12
SLIDE 12

Summary

  • Theorem: A language L is decidable if and only if it is

both recognizable and co-recognizable: D = RE ∩ coRE

RE co-RE Context-free Regular Decidable ??? ??? ??? Are there languages

  • utside of RE U coRE

Are there languages in RE - Dec? Are there languages in coRE - Dec?

slide-13
SLIDE 13

Undecidable languages

  • Are there languages that are not decidable?

E.g., HALT = {<M,w> | M is a TM such that M(w) terminates}

  • Claim: HALT is recognizable because it is the language of

the following TM MHALT(<M,w>) =

  • 1. Run M on input w.
  • 2. Accepts.
slide-14
SLIDE 14

Undecidable languages

  • Are there languages that are not decidable?

E.g., HALT = {<M,w> | M is a TM such that M(w) terminates}

  • Claim: HALT is recognizable because it is the language of

the following TM MHALT(<M,w>) =

  • 1. Run M on input w.
  • 2. Accepts.

Question: Is the claim correct? A) Yes, because L(MHALT)=HALT B) No, because MHALT may loop in step 1 C) No, because MHALT never rejects D) It depends on the input w

slide-15
SLIDE 15

Undecidable languages

  • Are there languages that are not decidable?

E.g., HALT = {<M,w> | M is a TM such that M(w) terminates}

  • Claim: HALT is recognizable because it is the language of

the following TM MHALT(<M,w>) =

  • 1. Run M on input w.
  • 2. Accepts.

Question: does MHALT decide HALT? A) Yes, because L(MHALT)=HALT B) No, because MHALT may loop in step 1 C) No, because MHALT never rejects D) It depends on the input w

slide-16
SLIDE 16

Summary

  • Theorem: A language L is decidable if and only if it is

both recognizable and co-recognizable: D = RE ∩ coRE

RE co-RE Context-free Regular Decidable ??? ??? ??? Are there languages

  • utside of RE U coRE

Is HALT in RE - Dec?

slide-17
SLIDE 17

Countable Sets

  • You can make an infjnite list of all natural numbers

N: 0,1,2,3,4,….

  • You can make an infjnite list containing all integers

Z: 0,1,-1,2,-2,3,-3,4,-4,…

  • Defjnition: a set S is countable if there is a

bijection f: N → S

Informally: you can list the elements of S: f(0),f(1),f(2),….

N and Z are countable

slide-18
SLIDE 18

Countable Sets

  • You can make an infjnite list of all natural numbers

N: 0,1,2,3,4,….

  • You can make an infjnite list containing all integers

Z: 0,1,-1,2,-2,3,-3,4,-4,…

  • Defjnition: a set S is countable if there is a

bijection f: N → S

Informally: you can list the elements of S: f(0),f(1),f(2),….

N and Z are countable Question: Is any of these sets countable? Q (rational numbers), R (real numbers), C (complex numbers) A) None of them is countable B) Q is countable, but R and C are not C) Q and R are countable, but C is not because D) They are all countable

slide-19
SLIDE 19

Diagonalization

  • Theorem: R is not countable.
  • Proof: assume for contradiction it is countable
  • List its element [0,1)

(1)0.0100010… (2)0.1101000… (3)0.0110001… (4)0.1010101… (5)0.1111000…

  • Flip the diagonal: r=0.10011…
  • The real number r is not on the list: Contradiction!
slide-20
SLIDE 20

There are non-recognizable languages

  • The set of all strings {0,1}* is countable

Just list them in lexicographic order: [w[i]]i = ε,0,1,00,01,10,11,000,…

  • The set of all Turing machines is countable because TM can be

represented by strings.

  • Languages can be represented by real numbers:

r=0.10010101011100…. ↔ {w[i] | the ith digit of r is 1}

  • The set of all languages P({0,1}*) is not countable
  • RE is strictly contained in P({0,1}*) because RE is countable and

P({0,1}*) is not.

slide-21
SLIDE 21

Next Time

  • Can we find specific (and possibly interesting) non-

recognizable languages?

  • Reading: Sipser Chapters 3 and 4
  • Friday Nov 11: Veterans’ day – No class
  • HW6 due on Nov 15
  • Haskell 4 due Nov 21
  • Exam 3: Nov 18