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/ T oday's learning goals Sipser Ch 1.4, 2.1 Introduction to T uring Machines Confjgurations and computations Deciders and Recognizers ??? ???


slide-1
SLIDE 1

CSE 105

THEORY OF COMPUTATION

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

slide-2
SLIDE 2

T

  • day's learning goals Sipser Ch 1.4, 2.1
  • Introduction to T

uring Machines

  • Confjgurations and computations
  • Deciders and Recognizers
slide-3
SLIDE 3

Context-free languages Context-free languages Regular languages Regular languages ??? ???

slide-4
SLIDE 4

T uring machines

  • Unlimited input
  • Unlimited (read/write)

memory

  • Unlimited time
slide-5
SLIDE 5

T uring machine computation

  • Read/write head starts at leftmost position on tape
  • Input string written on leftmost squares of tape, rest is

blank

  • Computation proceeds according to transition function:
  • Given current state of machine, and current symbol being read
  • the machine
  • transitions to new state
  • writes a symbol to its current position (overwriting existing symbol)
  • moves the tape head L or R
  • Computation ends if and when it enters either the accept
  • r the reject state.
slide-6
SLIDE 6

Formal defjnition of TM

qreject ≠ qaccept qreject ≠ qaccept

Is this a deterministic model? A) Yes B) No C) It depends on the state diagram D) It depends on the input E) I don’t know

slide-7
SLIDE 7

T uring Machine example

  • L = {w#w | w in {a,b}*} (No CFG/PDA!)
  • Informal description: Γ = {a,b,#,c,[_]}

1) If input is #

1) Move right skipping all c’s 2) If input is [_], then accept, else reject

2) Read a or b, store in internal state, and change it to c 3) Move right until read # 4) Move right skipping all c’s 5) Read a or b, matching the symbol read in step 1.

1) If mismatch → reject 2) If match, overwrite with c

6) Move left until read # 7) Move left until read c 8) Go back to 1).

slide-8
SLIDE 8

T uring Machine (formal)

  • L = {w#w | w in {a,b}*} (No CFG/PDA!)
  • Draw state diagram in JFLAP
slide-9
SLIDE 9

T uring Machine Computations

  • Confjguration: all the information store by the

system at any point during computation

Internal state (Q)

T ape content (Γ*)

Position of tape head

  • Formally: (α,q,β) in Γ* x Q x Γ*

q: internal state

α: tape content to the left of tape head

β: tape content from tape head to the right

slide-10
SLIDE 10

TM Computations

  • Fix TM M=(Q,Σ,Γ,δ,qs,qa,qr)
  • Computation of M on input w:

Sequence of confjgurations

Start from initial confjguration C0=(ε,qs,w)

Move from one confjguration Ci to the next Ci+1 according to δ

Until reaching halting confjguration (…,qa,…) or (…,qr,…)

  • Input is accepted if fjnal state is qa
  • Input is rejected if fjnal state is qr
slide-11
SLIDE 11

TM Computations

  • Fix TM M=(Q,Σ,Γ,δ,qs,qa,qr)
  • Computation of M on input w:

Sequence of confjgurations

Start from initial confjguration C0=(ε,qs,w)

Move from one confjguration Ci to the next Ci+1 according to δ

Until reaching halting confjguration (…,qa,…) or (…,qr,…)

  • Input is accepted if fjnal state is qa
  • Input is rejected if fjnal state is qr

What is the maximum length

  • f a computation?

A) Same as input length B) At most length of input C) May be longer than input, but it is always fjnite D) May be fjnite or infjnite E) I don’t know

slide-12
SLIDE 12

TM Computations

  • Fix TM M=(Q,Σ,Γ,δ,qs,qa,qr)
  • Computation of M on input w:

Sequence of confjgurations

Start from initial confjguration C0=(ε,qs,w)

Move from one confjguration Ci to the next Ci+1 according to δ

Until reaching halting confjguration (…,qa,…) or (…,qr,…)

  • Input is accepted if fjnal state is qa
  • Input is rejected if fjnal state is qr

Does M need to read the whole input w before halting? A) Yes, computation terminates

  • nly after reading w

B) Only before accepting w C) No. M may accept or reject without reading w entirely D) I don’t know

slide-13
SLIDE 13

TM Computations

  • Fix TM M=(Q,Σ,Γ,δ,qs,qa,qr)
  • Computation of M on input w:

Sequence of confjgurations

Start from initial confjguration C0=(ε,qs,w)

Move from one confjguration Ci to the next Ci+1 according to δ

Until reaching halting confjguration (…,qa,…) or (…,qr,…)

  • Input is accepted if fjnal state is qa
  • Input is rejected if fjnal state is qr

Which of the following is true? A) Computation may visit both qa and qr B) Computation may visit qa more than once C)Computation may visit qb more than once D) Computation may visit qs more than once E) None of the above

slide-14
SLIDE 14

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-15
SLIDE 15

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 Which of the following is true? A) If X is decidable, then X is recognizable B) If X is recognizable, then X is recognizable C) If X is decidable, then X is decidable D) A and C, but not C E) I can’t decide, I do not recognize this question :(

slide-16
SLIDE 16

Reminders

  • Reading: Sipser Chapter 3
  • HW5 due Monday Oct 31
  • Review for Exam 2
  • T

uesday Nov 1 TBA

  • Exam 2 Wednesday Nov 2
  • Seating chart: see Piazza
  • Study guide: see Piazza
  • Haskell 3 on CFG is out. Due Nov 7.