Big picture All languages Decidable Turing machines NP P - - PowerPoint PPT Presentation

big picture
SMART_READER_LITE
LIVE PREVIEW

Big picture All languages Decidable Turing machines NP P - - PowerPoint PPT Presentation

Big picture All languages Decidable Turing machines NP P Context-free Context-free grammars, push-down automata Regular Automata, non-deterministic automata, regular expressions Turing Machines Like DFA but Access


slide-1
SLIDE 1
  • All languages
  • Decidable

Turing machines

  • NP
  • P
  • Context-free

Context-free grammars, push-down automata

  • Regular

Automata, non-deterministic automata, regular expressions

Big picture

slide-2
SLIDE 2

Turing Machines

Like DFA but

  • Access to infinite tape,

initially containing input and blank (–) everywhere else

  • Read and write on tape
  • Move both ways on tape
  • Accept, reject take action immediately

1 0 0 1 – – – – …...

slide-3
SLIDE 3

Turing Machines (TM)

Details:

  • Tape is infinite to the right only
  • TM has head V on one tape cell
  • In one step TM can:
  • change state
  • read/write cell under head,
  • move to the left or right of 1 cell

(If TM attempts to go left of first cell, stay put) 0 1 – – …... V

slide-4
SLIDE 4

May write TM like DFA with transitions:

  • If in state q0 and tape cell under head contains 1:

write blank ( _ ), move head to the Right, go to state q1 1 → _ ,R q0 q1

slide-5
SLIDE 5

Example: L = {anbncn : n ≥ 0}

a→#,R

scan a's ACCEPT REJECT

_→R {b,c} → R {c,_}→R _ → L {a,b,c,x} → L b→x,R {b,x} → R c→x,R

scan b's scan c's go left

{a,b} → R {a,_}→R

find next a

_ → R {a,x} → R {c,x} → R a→x,R x → R # → R

slide-6
SLIDE 6
  • Typically, we do not draw state diagrams of TM
  • Two reasons:
  • State diagrams are very complicated, hence useless
  • There is equivalent, easier notation (we'll see later)
  • Sufficient to give high-level description of TM
slide-7
SLIDE 7

Example: A TM for the language {anbncn : n ≥ 0} M := “On input w. 1) Scan tape and cross off one a, one b, and one c 2) If none of these symbols is found, ACCEPT 3) If not all of these symbols is found,

  • r if found in the wrong order, REJECT

4) Go back to 1.”

  • State diagram merely implements above
slide-8
SLIDE 8

Example: A TM for the language {anbncn : n ≥ 0} M := “On input w. 1) Scan tape and cross off one a, one b, and one c 2) If none of these symbols is found, ACCEPT 3) If not all of these symbols is found,

  • r if found in the wrong order, REJECT

4) Go back to 1.”

  • State diagram merely implements above

Have extra tape symbols #, X

slide-9
SLIDE 9

L = {anbncn : n ≥ 0} a a b b c c – … –

a→#,R

scan a's ACCEPT REJECT

_→R {b,c} → R {c,_}→R _ → L {a,b,c,x} → L b→x,R {b,x} → R c→x,R

scan b's scan c's go left

{a,b} → R {a,_}→R

V

find next a

_ → R {a,x} → R {c,x} → R a→x,R x → R # → R

slide-10
SLIDE 10

L = {anbncn : n ≥ 0} a a b b c c – … –

a→#,R

scan a's ACCEPT REJECT

_→R {b,c} → R {c,_}→R _ → L {a,b,c,x} → L b→x,R {b,x} → R c→x,R

scan b's scan c's go left

{a,b} → R {a,_}→R

V

find next a

_ → R {a,x} → R {c,x} → R a→x,R x → R # → R

we don't write the symbol twice if it doesn't change

slide-11
SLIDE 11

L = {anbncn : n ≥ 0} a a b b c c – … –

a→#,R

scan a's ACCEPT REJECT

_→R {b,c} → R {c,_}→R _ → L {a,b,c,x} → L b→x,R {b,x} → R c→x,R

scan b's scan c's go left

{a,b} → R {a,_}→R

V

find next a

_ → R {a,x} → R {c,x} → R a→x,R x → R # → R

“if tape square is a or b, go right and move to REJECT”

slide-12
SLIDE 12

L = {anbncn : n ≥ 0} a a b b c c – … –

a→#,R

scan a's ACCEPT REJECT

_→R {b,c} → R {c,_}→R _ → L {a,b,c,x} → L b→x,R {b,x} → R c→x,R

scan b's scan c's go left

{a,b} → R {a,_}→R

V

find next a

_ → R {a,x} → R {c,x} → R a→x,R x → R # → R

BEGIN

slide-13
SLIDE 13

L = {anbncn : n ≥ 0} a # b b c c – … –

scan a's

a→#,R

ACCEPT REJECT

_→R {b,c} → R {c,_}→R _ → L {a,b,c,x} → L b→x,R {b,x} → R c→x,R

scan b's scan c's go left

{a,b} → R {a,_}→R

V

find next a

_ → R {a,x} → R {c,x} → R a→x,R x → R # → R

slide-14
SLIDE 14

L = {anbncn : n ≥ 0} # a b b c c – … –

a→#,R

scan a's ACCEPT REJECT

_→R {b,c} → R {c,_}→R _ → L {a,b,c,x} → L b→x,R {b,x} → R c→x,R

scan b's scan c's go left

{a,b} → R {a,_}→R

V

find next a

_ → R {a,x} → R {c,x} → R a→x,R x → R # → R

slide-15
SLIDE 15

L = {anbncn : n ≥ 0} # a b c c – … –

a→#,R

scan a's ACCEPT REJECT

_→R {b,c} → R {c,_}→R _ → L {a,b,c,x} → L b→x,R {b,x} → R c→x,R

scan b's scan c's go left

{a,b} → R {a,_}→R

V

find next a

_ → R {a,x} → R {c,x} → R a→x,R x → R # → R

x

slide-16
SLIDE 16

L = {anbncn : n ≥ 0} # a x b c c – … –

a→#,R

scan a's ACCEPT REJECT

_→R {b,c} → R {c,_}→R _ → L {a,b,c,x} → L b→x,R {b,x} → R c→x,R

scan b's scan c's go left

{a,b} → R {a,_}→R

V

find next a

_ → R {a,x} → R {c,x} → R a→x,R x → R # → R

slide-17
SLIDE 17

L = {anbncn : n ≥ 0} # a x b c – … –

a→#,R

scan a's ACCEPT REJECT

_→R {b,c} → R {c,_}→R _ → L {a,b,c,x} → L b→x,R {b,x} → R c→x,R

scan b's scan c's go left

{a,b} → R {a,_}→R

V

find next a

_ → R {a,x} → R {c,x} → R a→x,R x → R # → R

x

slide-18
SLIDE 18

L = {anbncn : n ≥ 0} # a x b x c – … –

a→#,R

scan a's ACCEPT REJECT

_→R {b,c} → R {c,_}→R _ → L {a,b,c,x} → L b→x,R {b,x} → R c→x,R

scan b's scan c's go left

{a,b} → R {a,_}→R

V

find next a

_ → R {a,x} → R {c,x} → R a→x,R x → R # → R

slide-19
SLIDE 19

L = {anbncn : n ≥ 0} # a x b x c – … –

a→#,R

scan a's ACCEPT REJECT

_→R {b,c} → R {c,_}→R _ → L {a,b,c,x} → L b→x,R {b,x} → R c→x,R

scan b's scan c's go left

{a,b} → R {a,_}→R

V

find next a

_ → R {a,x} → R {c,x} → R a→x,R x → R # → R

slide-20
SLIDE 20

L = {anbncn : n ≥ 0} # a x b x c – … –

a→#,R

scan a's ACCEPT REJECT

_→R {b,c} → R {c,_}→R _ → L {a,b,c,x} → L b→x,R {b,x} → R c→x,R

scan b's scan c's go left

{a,b} → R {a,_}→R

V

find next a

_ → R {a,x} → R {c,x} → R a→x,R x → R # → R

slide-21
SLIDE 21

L = {anbncn : n ≥ 0} # a x b x c – … –

a→#,R

scan a's ACCEPT REJECT

_→R {b,c} → R {c,_}→R _ → L {a,b,c,x} → L b→x,R {b,x} → R c→x,R

scan b's scan c's go left

{a,b} → R {a,_}→R

V

find next a

_ → R {a,x} → R {c,x} → R a→x,R x → R # → R

slide-22
SLIDE 22

L = {anbncn : n ≥ 0} # a x b x c – … –

a→#,R

scan a's ACCEPT REJECT

_→R {b,c} → R {c,_}→R _ → L {a,b,c,x} → L b→x,R {b,x} → R c→x,R

scan b's scan c's go left

{a,b} → R {a,_}→R

V

find next a

_ → R {a,x} → R {c,x} → R a→x,R x → R # → R

slide-23
SLIDE 23

L = {anbncn : n ≥ 0} # a x b x c – … –

a→#,R

scan a's ACCEPT REJECT

_→R {b,c} → R {c,_}→R _ → L {a,b,c,x} → L b→x,R {b,x} → R c→x,R

scan b's scan c's go left

{a,b} → R {a,_}→R

V

find next a

_ → R {a,x} → R {c,x} → R a→x,R x → R # → R

slide-24
SLIDE 24

L = {anbncn : n ≥ 0} # a x b x c – … –

a→#,R

scan a's ACCEPT REJECT

_→R {b,c} → R {c,_}→R _ → L {a,b,c,x} → L b→x,R {b,x} → R c→x,R

scan b's scan c's go left

{a,b} → R {a,_}→R

V

find next a

_ → R {a,x} → R {c,x} → R a→x,R x → R # → R

slide-25
SLIDE 25

L = {anbncn : n ≥ 0} # a x b x c – … –

a→#,R

scan a's ACCEPT REJECT

_→R {b,c} → R {c,_}→R _ → L {a,b,c,x} → L b→x,R {b,x} → R c→x,R

scan b's scan c's go left

{a,b} → R {a,_}→R

V

find next a

_ → R {a,x} → R {c,x} → R a→x,R x → R # → R

slide-26
SLIDE 26

L = {anbncn : n ≥ 0} # x b x c – … –

a→#,R

scan a's ACCEPT REJECT

_→R {b,c} → R {c,_}→R _ → L {a,b,c,x} → L b→x,R {b,x} → R c→x,R

scan b's scan c's go left

{a,b} → R {a,_}→R

V

find next a

_ → R {a,x} → R {c,x} → R a→x,R x → R # → R

x

slide-27
SLIDE 27

L = {anbncn : n ≥ 0} # x x b x c – … –

a→#,R

scan a's ACCEPT REJECT

_→R {b,c} → R {c,_}→R _ → L {a,b,c,x} → L b→x,R {b,x} → R c→x,R

scan b's scan c's go left

{a,b} → R {a,_}→R

V

find next a

_ → R {a,x} → R {c,x} → R a→x,R x → R # → R

slide-28
SLIDE 28

L = {anbncn : n ≥ 0} …

a→#,R

scan a's ACCEPT REJECT

_→R {b,c} → R {c,_}→R _ → L {a,b,c,x} → L b→x,R {b,x} → R c→x,R

scan b's scan c's go left

{a,b} → R {a,_}→R

V

find next a

_ → R {a,x} → R {c,x} → R a→x,R x → R # → R

# x x x c – – x

slide-29
SLIDE 29

L = {anbncn : n ≥ 0} # x x x x c – … –

a→#,R

scan a's ACCEPT REJECT

_→R {b,c} → R {c,_}→R _ → L {a,b,c,x} → L b→x,R {b,x} → R c→x,R

scan b's scan c's go left

{a,b} → R {a,_}→R

V

find next a

_ → R {a,x} → R {c,x} → R a→x,R x → R # → R

slide-30
SLIDE 30

L = {anbncn : n ≥ 0} …

a→#,R

scan a's ACCEPT REJECT

_→R {b,c} → R {c,_}→R _ → L {a,b,c,x} → L b→x,R {b,x} → R c→x,R

scan b's scan c's go left

{a,b} → R {a,_}→R

V

find next a

_ → R {a,x} → R {c,x} → R a→x,R x → R # → R

# x x x x – – x

slide-31
SLIDE 31

L = {anbncn : n ≥ 0} # x x x x x – … –

a→#,R

scan a's ACCEPT REJECT

_→R {b,c} → R {c,_}→R _ → L {a,b,c,x} → L b→x,R {b,x} → R c→x,R

scan b's scan c's go left

{a,b} → R {a,_}→R

V

find next a

_ → R {a,x} → R {c,x} → R a→x,R x → R # → R

slide-32
SLIDE 32

L = {anbncn : n ≥ 0} # x x x x x – … –

a→#,R

scan a's ACCEPT REJECT

_→R {b,c} → R {c,_}→R _ → L {a,b,c,x} → L b→x,R {b,x} → R c→x,R

scan b's scan c's go left

{a,b} → R {a,_}→R

V

find next a

_ → R {a,x} → R {c,x} → R a→x,R x → R # → R

slide-33
SLIDE 33

L = {anbncn : n ≥ 0} # x x x x x – … –

a→#,R

scan a's ACCEPT REJECT

_→R {b,c} → R {c,_}→R _ → L {a,b,c,x} → L b→x,R {b,x} → R c→x,R

scan b's scan c's go left

{a,b} → R {a,_}→R

V

find next a

_ → R {a,x} → R {c,x} → R a→x,R x → R # → R

slide-34
SLIDE 34

L = {anbncn : n ≥ 0} # x x x x x – … –

a→#,R

scan a's ACCEPT REJECT

_→R {b,c} → R {c,_}→R _ → L {a,b,c,x} → L b→x,R {b,x} → R c→x,R

scan b's scan c's go left

{a,b} → R {a,_}→R

V

find next a

_ → R {a,x} → R {c,x} → R a→x,R x → R # → R

slide-35
SLIDE 35

L = {anbncn : n ≥ 0} # x x x x x – … –

a→#,R

scan a's ACCEPT REJECT

_→R {b,c} → R {c,_}→R _ → L {a,b,c,x} → L b→x,R {b,x} → R c→x,R

scan b's scan c's go left

{a,b} → R {a,_}→R

V

find next a

_ → R {a,x} → R {c,x} → R a→x,R x → R # → R

slide-36
SLIDE 36

L = {anbncn : n ≥ 0} # x x x x x – … –

a→#,R

scan a's ACCEPT REJECT

_→R {b,c} → R {c,_}→R _ → L {a,b,c,x} → L b→x,R {b,x} → R c→x,R

scan b's scan c's go left

{a,b} → R {a,_}→R

V

find next a

_ → R {a,x} → R {c,x} → R a→x,R x → R # → R

slide-37
SLIDE 37

L = {anbncn : n ≥ 0} # x x x x x – … –

a→#,R

scan a's ACCEPT REJECT

_→R {b,c} → R {c,_}→R _ → L {a,b,c,x} → L b→x,R {b,x} → R c→x,R

scan b's scan c's go left

{a,b} → R {a,_}→R

V

find next a

_ → R {a,x} → R {c,x} → R a→x,R x → R # → R

slide-38
SLIDE 38

L = {anbncn : n ≥ 0} # x x x x x – … –

a→#,R

scan a's ACCEPT REJECT

_→R {b,c} → R {c,_}→R _ → L {a,b,c,x} → L b→x,R {b,x} → R c→x,R

scan b's scan c's go left

{a,b} → R {a,_}→R

V

find next a

_ → R {a,x} → R {c,x} → R a→x,R x → R # → R

slide-39
SLIDE 39

L = {anbncn : n ≥ 0} # x x x x x – … –

a→#,R

scan a's ACCEPT REJECT

_→R {b,c} → R {c,_}→R _ → L {a,b,c,x} → L b→x,R {b,x} → R c→x,R

scan b's scan c's go left

{a,b} → R {a,_}→R

V

find next a

_ → R {a,x} → R {c,x} → R a→x,R x → R # → R

slide-40
SLIDE 40

L = {anbncn : n ≥ 0} # x x x x x – … –

a→#,R

scan a's ACCEPT REJECT

_→R {b,c} → R {c,_}→R _ → L {a,b,c,x} → L b→x,R {b,x} → R c→x,R

scan b's scan c's go left

{a,b} → R {a,_}→R

V

find next a

_ → R {a,x} → R {c,x} → R a→x,R x → R # → R

slide-41
SLIDE 41

L = {anbncn : n ≥ 0} # x x x x x – … –

a→#,R

scan a's ACCEPT REJECT

_→R {b,c} → R {c,_}→R _ → L {a,b,c,x} → L b→x,R {b,x} → R c→x,R

scan b's scan c's go left

{a,b} → R {a,_}→R

V

find next a

_ → R {a,x} → R {c,x} → R a→x,R x → R # → R

slide-42
SLIDE 42

L = {anbncn : n ≥ 0} # x x x x x – … –

a→#,R

scan a's ACCEPT REJECT

_→R {b,c} → R {c,_}→R _ → L {a,b,c,x} → L b→x,R {b,x} → R c→x,R

scan b's scan c's go left

{a,b} → R {a,_}→R

V

find next a

_ → R {a,x} → R {c,x} → R a→x,R x → R # → R

slide-43
SLIDE 43

L = {anbncn : n ≥ 0} # x x x x x – … –

a→#,R

scan a's ACCEPT REJECT

_→R {b,c} → R {c,_}→R _ → L {a,b,c,x} → L b→x,R {b,x} → R c→x,R

scan b's scan c's go left

{a,b} → R {a,_}→R

V

find next a

_ → R {a,x} → R {c,x} → R a→x,R x → R # → R

DONE!

slide-44
SLIDE 44

L = {anbncn : n ≥ 0} a a b b b c – … –

a→#,R

scan a's

_→R {b,c} → R {c,_}→R _ → L {a,b,c,x} → L b→x,R {b,x} → R c→x,R

scan b's scan c's

{a,b} → R {a,_}→R

V

_ → R {a,x} → R {c,x} → R a→x,R x → R # → R

ACCEPT REJECT go left find next a

Now a REJECT example

slide-45
SLIDE 45

L = {anbncn : n ≥ 0} a a b b b c – … –

a→#,R

scan a's

_→R {b,c} → R {c,_}→R _ → L {a,b,c,x} → L b→x,R {b,x} → R c→x,R

scan b's scan c's

{a,b} → R {a,_}→R

V

_ → R {a,x} → R {c,x} → R a→x,R x → R # → R

ACCEPT REJECT go left find next a

BEGIN

slide-46
SLIDE 46

L = {anbncn : n ≥ 0} a b b b c – … –

a→#,R

scan a's

_→R {b,c} → R {c,_}→R _ → L {a,b,c,x} → L b→x,R {b,x} → R c→x,R

scan b's scan c's

{a,b} → R {a,_}→R

V

_ → R {a,x} → R {c,x} → R a→x,R x → R # → R

ACCEPT REJECT go left find next a

#

slide-47
SLIDE 47

L = {anbncn : n ≥ 0} # a b b b c – … –

a→#,R

scan a's

_→R {b,c} → R {c,_}→R _ → L {a,b,c,x} → L b→x,R {b,x} → R c→x,R

scan b's scan c's

{a,b} → R {a,_}→R

V

_ → R {a,x} → R {c,x} → R a→x,R x → R # → R

ACCEPT REJECT go left find next a

slide-48
SLIDE 48

L = {anbncn : n ≥ 0} # a b b c – … –

a→#,R

scan a's

_→R {b,c} → R {c,_}→R _ → L {a,b,c,x} → L b→x,R {b,x} → R c→x,R

scan b's scan c's

{a,b} → R {a,_}→R

V

_ → R {a,x} → R {c,x} → R a→x,R x → R # → R

ACCEPT REJECT go left find next a

x

slide-49
SLIDE 49

L = {anbncn : n ≥ 0} # a x b b c – … –

a→#,R

scan a's

_→R {b,c} → R {c,_}→R _ → L {a,b,c,x} → L b→x,R {b,x} → R c→x,R

scan b's scan c's

{a,b} → R {a,_}→R

V

_ → R {a,x} → R {c,x} → R a→x,R x → R # → R

ACCEPT REJECT go left find next a

slide-50
SLIDE 50

L = {anbncn : n ≥ 0} # a x b b c – … –

a→#,R

scan a's

_→R {b,c} → R {c,_}→R _ → L {a,b,c,x} → L b→x,R {b,x} → R c→x,R

scan b's scan c's

{a,b} → R {a,_}→R

V

_ → R {a,x} → R {c,x} → R a→x,R x → R # → R

ACCEPT REJECT go left find next a

slide-51
SLIDE 51

L = {anbncn : n ≥ 0} # a x b b – … –

a→#,R

scan a's

_→R {b,c} → R {c,_}→R _ → L {a,b,c,x} → L b→x,R {b,x} → R c→x,R

scan b's scan c's

{a,b} → R {a,_}→R

V

_ → R {a,x} → R {c,x} → R a→x,R x → R # → R

ACCEPT REJECT go left find next a

x

slide-52
SLIDE 52

L = {anbncn : n ≥ 0} # a x b b x – … –

a→#,R

scan a's

_→R {b,c} → R {c,_}→R _ → L {a,b,c,x} → L b→x,R {b,x} → R c→x,R

scan b's scan c's

{a,b} → R {a,_}→R

V

_ → R {a,x} → R {c,x} → R a→x,R x → R # → R

ACCEPT REJECT go left find next a

slide-53
SLIDE 53

L = {anbncn : n ≥ 0} # a x b b x – … –

a→#,R

scan a's

_→R {b,c} → R {c,_}→R _ → L {a,b,c,x} → L b→x,R {b,x} → R c→x,R

scan b's scan c's

{a,b} → R {a,_}→R

V

_ → R {a,x} → R {c,x} → R a→x,R x → R # → R

ACCEPT REJECT go left find next a

slide-54
SLIDE 54

L = {anbncn : n ≥ 0} # a x b b x – … –

a→#,R

scan a's

_→R {b,c} → R {c,_}→R _ → L {a,b,c,x} → L b→x,R {b,x} → R c→x,R

scan b's scan c's

{a,b} → R {a,_}→R

V

_ → R {a,x} → R {c,x} → R a→x,R x → R # → R

ACCEPT REJECT go left find next a

slide-55
SLIDE 55

L = {anbncn : n ≥ 0} # a x b b x – … –

a→#,R

scan a's

_→R {b,c} → R {c,_}→R _ → L {a,b,c,x} → L b→x,R {b,x} → R c→x,R

scan b's scan c's

{a,b} → R {a,_}→R

V

_ → R {a,x} → R {c,x} → R a→x,R x → R # → R

ACCEPT REJECT go left find next a

slide-56
SLIDE 56

L = {anbncn : n ≥ 0} # a x b b x – … –

a→#,R

scan a's

_→R {b,c} → R {c,_}→R _ → L {a,b,c,x} → L b→x,R {b,x} → R c→x,R

scan b's scan c's

{a,b} → R {a,_}→R

V

_ → R {a,x} → R {c,x} → R a→x,R x → R # → R

ACCEPT REJECT go left find next a

slide-57
SLIDE 57

L = {anbncn : n ≥ 0} # a x b b x – … –

a→#,R

scan a's

_→R {b,c} → R {c,_}→R _ → L {a,b,c,x} → L b→x,R {b,x} → R c→x,R

scan b's scan c's

{a,b} → R {a,_}→R

V

_ → R {a,x} → R {c,x} → R a→x,R x → R # → R

ACCEPT REJECT go left find next a

slide-58
SLIDE 58

L = {anbncn : n ≥ 0} # a x b b x – … –

a→#,R

scan a's

_→R {b,c} → R {c,_}→R _ → L {a,b,c,x} → L b→x,R {b,x} → R c→x,R

scan b's scan c's

{a,b} → R {a,_}→R

V

_ → R {a,x} → R {c,x} → R a→x,R x → R # → R

ACCEPT REJECT go left find next a

slide-59
SLIDE 59

L = {anbncn : n ≥ 0} # x b b x – … –

a→#,R

scan a's

_→R {b,c} → R {c,_}→R _ → L {a,b,c,x} → L b→x,R {b,x} → R c→x,R

scan b's scan c's

{a,b} → R {a,_}→R

V

_ → R {a,x} → R {c,x} → R a→x,R x → R # → R

ACCEPT REJECT go left find next a

x

slide-60
SLIDE 60

L = {anbncn : n ≥ 0} # x x b b x – … –

a→#,R

scan a's

_→R {b,c} → R {c,_}→R _ → L {a,b,c,x} → L b→x,R {b,x} → R c→x,R

scan b's scan c's

{a,b} → R {a,_}→R

V

_ → R {a,x} → R {c,x} → R a→x,R x → R # → R

ACCEPT REJECT go left find next a

slide-61
SLIDE 61

L = {anbncn : n ≥ 0} # x x b x – … –

a→#,R

scan a's

_→R {b,c} → R {c,_}→R _ → L {a,b,c,x} → L b→x,R {b,x} → R c→x,R

scan b's scan c's

{a,b} → R {a,_}→R

V

_ → R {a,x} → R {c,x} → R a→x,R x → R # → R

ACCEPT REJECT go left find next a

x

slide-62
SLIDE 62

L = {anbncn : n ≥ 0} # x x x b x – … –

a→#,R

scan a's

_→R {b,c} → R {c,_}→R _ → L {a,b,c,x} → L b→x,R {b,x} → R c→x,R

scan b's scan c's

{a,b} → R {a,_}→R

V

_ → R {a,x} → R {c,x} → R a→x,R x → R # → R

ACCEPT REJECT go left find next a

slide-63
SLIDE 63

L = {anbncn : n ≥ 0} # x x x b x – … –

a→#,R

scan a's

_→R {b,c} → R {c,_}→R _ → L {a,b,c,x} → L b→x,R {b,x} → R c→x,R

scan b's scan c's

{a,b} → R {a,_}→R

V

_ → R {a,x} → R {c,x} → R a→x,R x → R # → R

ACCEPT REJECT go left find next a

slide-64
SLIDE 64

L = {anbncn : n ≥ 0} # x x x b x – … –

a→#,R

scan a's

_→R {b,c} → R {c,_}→R _ → L {a,b,c,x} → L b→x,R {b,x} → R c→x,R

scan b's scan c's

{a,b} → R {a,_}→R

V

_ → R {a,x} → R {c,x} → R a→x,R x → R # → R

ACCEPT REJECT go left find next a

DONE!

slide-65
SLIDE 65

Example: TM for L = {a : n  0}

= {a, aa, aaaa, aaaaaaaa, … }

2n

M := “On input w, 1) if only one a, ACCEPT 2) cross off every other a on the tape 3) if the number of a's is odd, REJECT 4) Go back to 1)” For instance: 8 a's → 4 a's → 2 a's → 1 a → ACCEPT 12 a's → 6 a's → 3 a's → REJECT

slide-66
SLIDE 66

Another example: L = {a : n  0}

2n

a a a a – – V

x→R

REJECT mark the next a skip the next a

go left

ACCEPT

a → #,R x→R x→R x→R # → R _ → R a → R _ → R _ → L {a,x} → L a → x, R a → x, R a → R _ → R

slide-67
SLIDE 67

Another example: L = {a : n  0}

2n

# a a a – – V

x→R

REJECT mark the next a skip the next a

go left

ACCEPT

a → #,R x→R x→R x→R # → R _ → R a → R _ → R _ → L {a,x} → L a → x, R a → x, R a → R _ → R

slide-68
SLIDE 68

Another example: L = {a : n  0}

2n

# a a a – – V

x→R

REJECT mark the next a skip the next a

go left

ACCEPT

a → #,R x→R x→R x→R # → R _ → R a → R _ → R _ → L {a,x} → L a → x, R a → x, R a → R _ → R

slide-69
SLIDE 69

Another example: L = {a : n  0}

2n

# a x a – – V

x→R

REJECT mark the next a skip the next a

go left

ACCEPT

a → #,R x→R x→R x→R # → R _ → R a → R _ → R _ → L {a,x} → L a → x, R a → x, R a → R _ → R

slide-70
SLIDE 70

Another example: L = {a : n  0}

2n

# a x a – – V

x→R

REJECT mark the next a skip the next a

go left

ACCEPT

a → #,R x→R x→R x→R # → R _ → R a → R _ → R _ → L {a,x} → L a → x, R a → x, R a → R _ → R

slide-71
SLIDE 71

Another example: L = {a : n  0}

2n

# a x a – – V

x→R

REJECT mark the next a skip the next a

go left

ACCEPT

a → #,R x→R x→R x→R # → R _ → R a → R _ → R _ → L {a,x} → L a → x, R a → x, R a → R _ → R

slide-72
SLIDE 72

Another example: L = {a : n  0}

2n

# a x a – – V

x→R

REJECT mark the next a skip the next a

go left

ACCEPT

a → #,R x→R x→R x→R # → R _ → R a → R _ → R _ → L {a,x} → L a → x, R a → x, R a → R _ → R

slide-73
SLIDE 73

Another example: L = {a : n  0}

2n

# a x a – – V

x→R

REJECT mark the next a skip the next a

go left

ACCEPT

a → #,R x→R x→R x→R # → R _ → R a → R _ → R _ → L {a,x} → L a → x, R a → x, R a → R _ → R

slide-74
SLIDE 74

Another example: L = {a : n  0}

2n

# a x a – – V

x→R

REJECT mark the next a skip the next a

go left

ACCEPT

a → #,R x→R x→R x→R # → R _ → R a → R _ → R _ → L {a,x} → L a → x, R a → x, R a → R _ → R

slide-75
SLIDE 75

Another example: L = {a : n  0}

2n

# a x a – – V

x→R

REJECT mark the next a skip the next a

go left

ACCEPT

a → #,R x→R x→R x→R # → R _ → R a → R _ → R _ → L {a,x} → L a → x, R a → x, R a → R _ → R

slide-76
SLIDE 76

Another example: L = {a : n  0}

2n

# x x a – – V

x→R

REJECT mark the next a skip the next a

go left

ACCEPT

a → #,R x→R x→R x→R # → R _ → R a → R _ → R _ → L {a,x} → L a → x, R a → x, R a → R _ → R

slide-77
SLIDE 77

Another example: L = {a : n  0}

2n

# x x a – – V

x→R

REJECT mark the next a skip the next a

go left

ACCEPT

a → #,R x→R x→R x→R # → R _ → R a → R _ → R _ → L {a,x} → L a → x, R a → x, R a → R _ → R

slide-78
SLIDE 78

Another example: L = {a : n  0}

2n

# x x a – – V

x→R

REJECT mark the next a skip the next a

go left

ACCEPT

a → #,R x→R x→R x→R # → R _ → R a → R _ → R _ → L {a,x} → L a → x, R a → x, R a → R _ → R

slide-79
SLIDE 79

Another example: L = {a : n  0}

2n

# x x a – – V

x→R

REJECT mark the next a skip the next a

go left

ACCEPT

a → #,R x→R x→R x→R # → R _ → R a → R _ → R _ → L {a,x} → L a → x, R a → x, R a → R _ → R

slide-80
SLIDE 80

Another example: L = {a : n  0}

2n

# x x a – – V

x→R

REJECT mark the next a skip the next a

go left

ACCEPT

a → #,R x→R x→R x→R # → R _ → R a → R _ → R _ → L {a,x} → L a → x, R a → x, R a → R _ → R

slide-81
SLIDE 81

Another example: L = {a : n  0}

2n

# x x a – – V

x→R

REJECT mark the next a skip the next a

go left

ACCEPT

a → #,R x→R x→R x→R # → R _ → R a → R _ → R _ → L {a,x} → L a → x, R a → x, R a → R _ → R

slide-82
SLIDE 82

Another example: L = {a : n  0}

2n

# x x a – – V

x→R

REJECT mark the next a skip the next a

go left

ACCEPT

a → #,R x→R x→R x→R # → R _ → R a → R _ → R _ → L {a,x} → L a → x, R a → x, R a → R _ → R

slide-83
SLIDE 83

Another example: L = {a : n  0}

2n

# x x a – – V

x→R

REJECT mark the next a skip the next a

go left

ACCEPT

a → #,R x→R x→R x→R # → R _ → R a → R _ → R _ → L {a,x} → L a → x, R a → x, R a → R _ → R

slide-84
SLIDE 84

Another example: L = {a : n  0}

2n

# x x a – – V

x→R

REJECT mark the next a skip the next a

go left

ACCEPT

a → #,R x→R x→R x→R # → R _ → R a → R _ → R _ → L {a,x} → L a → x, R a → x, R a → R _ → R

slide-85
SLIDE 85

Another example: L = {a : n  0}

2n

# x x a – – V

x→R

REJECT mark the next a skip the next a

go left

ACCEPT

a → #,R x→R x→R x→R # → R _ → R a → R _ → R _ → L {a,x} → L a → x, R a → x, R a → R _ → R

slide-86
SLIDE 86

Another example: L = {a : n  0}

2n

# x x x – – V

x→R

REJECT mark the next a skip the next a

go left

ACCEPT

a → #,R x→R x→R x→R # → R _ → R a → R _ → R _ → L {a,x} → L a → x, R a → x, R a → R _ → R

slide-87
SLIDE 87

Another example: L = {a : n  0}

2n

# x x x – – V

x→R

REJECT mark the next a skip the next a

go left

ACCEPT

a → #,R x→R x→R x→R # → R _ → R a → R _ → R _ → L {a,x} → L a → x, R a → x, R a → R _ → R

ACCEPT!

slide-88
SLIDE 88

Unlike DFA and PDA, TM computation may never halt. That is, it may continue forever without entering accept/reject states This is when your computer “freezes” a a – – – – V

{a,_} → R

Example

slide-89
SLIDE 89

Unlike DFA and PDA, TM computation may never halt. That is, it may continue forever without entering accept/reject states This is when your computer “freezes” a a – – – – V

{a,_} → R

Example

slide-90
SLIDE 90

Unlike DFA and PDA, TM computation may never halt. That is, it may continue forever without entering accept/reject states This is when your computer “freezes” a a – – – – V

{a,_} → R

Example

slide-91
SLIDE 91

Unlike DFA and PDA, TM computation may never halt. That is, it may continue forever without entering accept/reject states This is when your computer “freezes” a a – – – – V

{a,_} → R

Example And so on!

slide-92
SLIDE 92
  • Definition: A Turing Machine TM is a 7-tuple

(Q, ∑ , Γ , δ , q0, qaccept, qreject) where:

  • Q is a finite, non-empty set of states
  • ∑ is the input alphabet. Blank symbol _ ∑

  • Γ is the tape alphabet, ∑ Γ and _ Γ

⊆ ∈

  • δ : Q X Γ → Q x Γ x {L, R} is the transition function
  • q0 Q is the start state

  • qaccept Q is the accept state

  • qreject Q is the reject state; q

accept ≠ qreject

slide-93
SLIDE 93
  • Definition: A configuration of a TM specifies

contents of tape, state, head location

?

q7 . . . . . .

0 0 1 1 – –

It is written as u q v where q Q, u, v Γ* ∈ ∈ Meaning: 1) TM in state q 2) head is on first symbol of v. 3) Tape contains uv, blanks not shown

V

slide-94
SLIDE 94
  • Definition: A configuration of a TM specifies

contents of tape, state, head location

00q711

q7 . . . . . .

0 0 1 1 – –

It is written as u q v where q Q, u, v Γ* ∈ ∈ Meaning: 1) TM in state q 2) head is on first symbol of v. 3) Tape contains uv, blanks not shown

V

slide-95
SLIDE 95
  • Definition: A configuration C yields a configuration C'

if TM goes from C to C' in one step:

  • u a q b v yields u q' a c v if δ (q,b) = (q',c,L)
  • u a q b v yields u a c q' v if δ (q,b) = (q',c,R)
  • u a q is treated like u a q _
  • q b v yields q' c v if δ (q,b) = (q', c, L)
  • q b v yields c q' v if δ (q,b) = (q', c, R)
slide-96
SLIDE 96
  • Definition:

Start configuration of TM on input w is q0w Accept configuration: any configuration with qaccept Reject configuration: any configuration with qreject Halt (stop) configur.: Accept U Reject configur.

  • Definition: TM M accepts (rejects, halts on) input w if

∃configurations C1, C2, ..., Ck : C1 is start configuration Ci yields Ci+1 i < k ∀ Ck is accept (reject, halt) configuration

slide-97
SLIDE 97

Example: L = {a : n  0} q0 aaaa

2n

slide-98
SLIDE 98

Example: L = {a : n  0} q0 aaaa # q1 aaa

2n

slide-99
SLIDE 99

Example: L = {a : n  0}

2n

q0 aaaa # q1 aaa #a q2 aa

slide-100
SLIDE 100

Example: L = {a : n  0}

2n

q0 aaaa # q1 aaa #a q2 aa #ax q3 a

slide-101
SLIDE 101

Example: L = {a : n  0}

2n

q0 aaaa # q1 aaa #a q2 aa #ax q3 a #axa q2

slide-102
SLIDE 102

Example: L = {a : n  0}

2n

q0 aaaa # q1 aaa #a q2 aa #ax q3 a #axa q2 #ax q4 a

slide-103
SLIDE 103

Example: L = {a : n  0}

2n

q0 aaaa # q1 aaa #a q2 aa #ax q3 a #axa q2 #ax q4 a #a q4 xa

slide-104
SLIDE 104

Example: L = {a : n  0}

2n

q0 aaaa # q1 aaa #a q2 aa #ax q3 a #axa q2 #ax q4 a #a q4 xa # q4 axa

slide-105
SLIDE 105

Example: L = {a : n  0}

2n

q0 aaaa # q1 aaa #a q2 aa #ax q3 a #axa q2 #ax q4 a #a q4 xa # q4 axa q4 #axa

slide-106
SLIDE 106

Example: L = {a : n  0}

2n

q0 aaaa # q1 aaa #a q2 aa #ax q3 a #axa q2 #ax q4 a #a q4 xa # q4 axa q4 #axa # q5 axa

slide-107
SLIDE 107

Example: L = {a : n  0}

2n

q0 aaaa # q1 aaa #a q2 aa #ax q3 a #axa q2 #ax q4 a #a q4 xa # q4 axa q4 #axa # q5 axa #x q1 xa

slide-108
SLIDE 108

Example: L = {a : n  0}

2n

q0 aaaa # q1 aaa #a q2 aa #ax q3 a #axa q2 #ax q4 a #a q4 xa # q4 axa q4 #axa # q5 axa #x q1 xa #xx q1 a

slide-109
SLIDE 109

Example: L = {a : n  0}

2n

q0 aaaa # q1 aaa #a q2 aa #ax q3 a #axa q2 #ax q4 a #a q4 xa # q4 axa q4 #axa # q5 axa #x q1 xa #xx q1 a #xxa q2

slide-110
SLIDE 110

Example: L = {a : n  0}

2n

q0 aaaa # q1 aaa #a q2 aa #ax q3 a #axa q2 #ax q4 a #a q4 xa # q4 axa q4 #axa # q5 axa #x q1 xa #xx q1 a #xxa q2 #xx q4 a

slide-111
SLIDE 111

Example: L = {a : n  0}

2n

q0 aaaa # q1 aaa #a q2 aa #ax q3 a #axa q2 #ax q4 a #a q4 xa # q4 axa q4 #axa # q5 axa #x q1 xa #xx q1 a #xxa q2 #xx q4 a #x q4 xa

slide-112
SLIDE 112

Example: L = {a : n  0}

2n

q0 aaaa # q1 aaa #a q2 aa #ax q3 a #axa q2 #ax q4 a #a q4 xa # q4 axa q4 #axa # q5 axa #x q1 xa #xx q1 a #xxa q2 #xx q4 a #x q4 xa # q4 xxa

slide-113
SLIDE 113

Example: L = {a : n  0}

2n

q0 aaaa # q1 aaa #a q2 aa #ax q3 a #axa q2 #ax q4 a #a q4 xa # q4 axa q4 #axa # q5 axa #x q1 xa #xx q1 a #xxa q2 #xx q4 a #x q4 xa # q4 xxa q4 #xxa

slide-114
SLIDE 114

Example: L = {a : n  0}

2n

q0 aaaa # q1 aaa #a q2 aa #ax q3 a #axa q2 #ax q4 a #a q4 xa # q4 axa q4 #axa # q5 axa #x q1 xa #xx q1 a #xxa q2 #xx q4 a #x q4 xa # q4 xxa q4 #xxa # q5 xxa

slide-115
SLIDE 115

Example: L = {a : n  0}

2n

q0 aaaa # q1 aaa #a q2 aa #ax q3 a #axa q2 #ax q4 a #a q4 xa # q4 axa q4 #axa # q5 axa #x q1 xa #xx q1 a #xxa q2 #xx q4 a #x q4 xa # q4 xxa q4 #xxa # q5 xxa #x q5 xa

slide-116
SLIDE 116

Example: L = {a : n  0}

2n

q0 aaaa # q1 aaa #a q2 aa #ax q3 a #axa q2 #ax q4 a #a q4 xa # q4 axa q4 #axa # q5 axa #x q1 xa #xx q1 a #xxa q2 #xx q4 a #x q4 xa # q4 xxa q4 #xxa # q5 xxa #x q5 xa #xx q5 a

slide-117
SLIDE 117

Example: L = {a : n  0}

2n

q0 aaaa # q1 aaa #a q2 aa #ax q3 a #axa q2 #ax q4 a #a q4 xa # q4 axa q4 #axa # q5 axa #x q1 xa #xx q1 a #xxa q2 #xx q4 a #x q4 xa # q4 xxa q4 #xxa # q5 xxa #x q5 xa #xx q5 a #xxx q1

slide-118
SLIDE 118

Example: L = {a : n  0}

2n

q0 aaaa # q1 aaa #a q2 aa #ax q3 a #axa q2 #ax q4 a #a q4 xa # q4 axa q4 #axa # q5 axa #x q1 xa #xx q1 a #xxa q2 #xx q4 a #x q4 xa # q4 xxa q4 #xxa # q5 xxa #x q5 xa #xx q5 a #xxx q1 #xxx_ qACCEPT

slide-119
SLIDE 119
  • Definition: A language L is decidable

if a TM M such that for every input w ∃ w L M accepts w ∈ ⇨ w L M rejects w ∉ ⇨

  • Is this the same as

w L ∈  M accepts w ???

slide-120
SLIDE 120
  • Definition: A language L is decidable

if a TM M such that for every input w ∃ w L M accepts w ∈ ⇨ w L M rejects w ∉ ⇨

  • This is NOT the same as

w L ∈  M accepts w because M may LOOP FOREVER (freeze, crash,...)

  • We ask something more: TM halts on every input

Such a TM is called a decider

slide-121
SLIDE 121
  • Definition: The language of TM M is

L(M) = {w : M accepts w}

  • Recall this means w L(M)

∈  M accepts w

  • Definition: A language L is recognizable if TM M :

∃ L = L(M)

  • However we are more interested in decidable L
slide-122
SLIDE 122
  • So far, DFA, CFG, TM recognize languages
  • Since TM can write on tape, they can also compute

functions

  • Definition: A function f : ∑* → ∑* is computable if

∃a TM M such that on every input w ∑ * ∈ TM halts with f(w) on the tape

slide-123
SLIDE 123
  • All common functions such as +, x, /, etc.

are computable

  • Note: Consider for example + : x →

ℕ ℕ ℕ +(2,9) = 11 +(15,8) = 23 How to represent an input pair (a,b) x ? ∈ℕ ℕ

  • Any reasonable representation will do

For example, use extra symbols for ( ) and ,

slide-124
SLIDE 124
  • Example: Computing + : x →

ℕ ℕ ℕ ( 1 3 , 5 8 ) … – V –

slide-125
SLIDE 125
  • Example: Computing + : x →

ℕ ℕ ℕ ( 1 3 , 5 8 ) … – V – Goes on for many steps until...

slide-126
SLIDE 126
  • Example: Computing + : x →

ℕ ℕ ℕ 7 1 – – – – – … – V –

slide-127
SLIDE 127
  • How powerful are TM?
  • One can show that regular, and context-free

languages are decidable

  • We saw TM decide some non-context free

languages

  • We saw TM also compute functions
  • What else can a TM do?
slide-128
SLIDE 128
  • Suprisingly, TM are very powerful
  • Pick your favorite programming language, say JAVA
  • Theorem: For every language L :

L decidable in JAVA L decidable in TM 

  • Everything you program, you can do on a TM

Program, algorithm, TM, etc. all mean the same!

  • So why not use JAVA? Who cares about TM?
slide-129
SLIDE 129
  • JAVA and TM are equivalent. However,
  • To design programs, JAVA is more convenient.

Higher-level, shorter programs, human readable You do this in the Algorithms class

  • To understand fundamental limits of computing TM

is more convenient. Simpler description, configurations, head movement You do this in This class

slide-130
SLIDE 130
  • Main reason why TM better than JAVA for our aims
  • TM computation is local:

all action happens in tape symbols adjacent to head

  • Not true for JAVA:

no head, any tape (memory) symbol can change

  • Locality is exploited in several results we will see
  • Let us now make this more precise
slide-131
SLIDE 131
  • Fact: [Locality of TM computation]

TM configuration Ci yields Ci+1  ∀ j , the 6 symbols (Ci )j , (Ci )j+1 , (Ci )j+2 , (Ci+1 )j , (Ci+1 )j+1 , (Ci+1 )j+2 are consistent with TM transition function δ

  • Example Ci = # a q2 a a a b c x _ _

Ci+1 = # a x q3 a a b c x _ _ Consistent: δ(q2, σ) = (q, x, R) for some σ Γ, q Q ∈ ∈ Note: σ = a here, but that is not among the 6 symbols

slide-132
SLIDE 132
  • Fact: [Locality of TM computation]

TM configuration Ci yields Ci+1  ∀ j , the 6 symbols (Ci )j , (Ci )j+1 , (Ci )j+2 , (Ci+1 )j , (Ci+1 )j+1 , (Ci+1 )j+2 are consistent with TM transition function δ

  • Example Ci = # a q2 a a a b c x _ _

Ci+1 = # a x q3 a a b c x _ _ Consistent: δ(q2, a) = (q3, x, R) Note: Only one choice here!

slide-133
SLIDE 133
  • Fact: [Locality of TM computation]

TM configuration Ci yields Ci+1  ∀ j , the 6 symbols (Ci )j , (Ci )j+1 , (Ci )j+2 , (Ci+1 )j , (Ci+1 )j+1 , (Ci+1 )j+2 are consistent with TM transition function δ

  • Example Ci = # a q2 a a a b c x _ _

Ci+1 = # a x q3 a a b c x _ _ Consistent: δ(q2, a) = (q3, x, R) Note: Again only one choice here!

slide-134
SLIDE 134
  • Fact: [Locality of TM computation]

TM configuration Ci yields Ci+1  ∀ j , the 6 symbols (Ci )j , (Ci )j+1 , (Ci )j+2 , (Ci+1 )j , (Ci+1 )j+1 , (Ci+1 )j+2 are consistent with TM transition function δ

  • Example Ci = # a q2 a a a b c x _ _

Ci+1 = # a x q3 a a b c x _ _ Consistent: δ(q, a) = (q3, σ , R) for some q Q, σ Γ ∈ ∈ Note: q = q2, but that is not among the 6 symbols

slide-135
SLIDE 135
  • Fact: [Locality of TM computation]

TM configuration Ci yields Ci+1  ∀ j , the 6 symbols (Ci )j , (Ci )j+1 , (Ci )j+2 , (Ci+1 )j , (Ci+1 )j+1 , (Ci+1 )j+2 are consistent with TM transition function δ

  • Example Ci = # a q2 a a a b c x _ _

Ci+1 = # a x q3 a a b c x _ _ Consistent: j, hence C ∀

i yields Ci+1

slide-136
SLIDE 136
  • Fact: [Locality of TM computation]

TM configuration Ci yields Ci+1  ∀ j , the 6 symbols (Ci )j , (Ci )j+1 , (Ci )j+2 , (Ci+1 )j , (Ci+1 )j+1 , (Ci+1 )j+2 are consistent with TM transition function δ

  • Example Ci = # a q2 a a a b c x _ _

Ci+1 = # a q2 q3 a a b a x _ _

  • Not consistent
slide-137
SLIDE 137
  • Is there anything beyond JAVA / TM?
  • Church-Turing Thesis:

Anything that is “effectively computable” is computable on a TM

  • This is not a theorem. It is the belief that every

computational model humans may ever consider (DNA computing, quantum computing, etc.) will still be equivalent to TM

slide-138
SLIDE 138
  • So far, simple-looking languages like

{0n1n : n ≥ 0 }, { w : w {0,1}* }, {a ∈

ibjck : i ≤ j ≤ j}

  • Next: { D : D is a DFA and .... }

{ (M,w) : M is a TM and ... } { G : G is a graph and … }

  • How to represent D, (M,w), G is not important

Any reasonable representation will do!

  • Example, use formal definitions over ∑ = {a,b,c,....}
slide-139
SLIDE 139
  • Is there anything a TM cannot do?
  • Definition:ATM = {(M,w) : M is a TM and M accepts w}
  • We are going to prove ATM undecidable:
  • Interpretation: Your friend comes to you with a piece

a code M and some input w and says: M accepts w!

  • Nobody can tell! …can't you just run M on w?
slide-140
SLIDE 140
  • Is there anything a TM cannot do?
  • Definition:ATM = {(M,w) : M is a TM and M accepts w}
  • We are going to prove ATM undecidable:
  • Interpretation: Your friend comes to you with a piece

a code M and some input w and says: M accepts w!

  • Nobody can tell! …can't you just run M on w?
  • NO. M on w may never halt. But a decider must halt!
slide-141
SLIDE 141
  • Theorem: ATM= {(M,w) : M is a TM and M accepts w}

is undecidable

  • Idea: Proof by contradiction
slide-142
SLIDE 142
  • Theorem: ATM= {(M,w) : M is a TM and M accepts w}

is undecidable

  • Idea: Proof by contradiction

(1) We assume we have a decider D for ATM (2) Using D, we derive a logical contradiction. How ? (3) We conclude that assumption (1) is false, D cannot exist, and so ATM is undecidable

slide-143
SLIDE 143
  • Theorem: ATM= {(M,w) : M is a TM and M accepts w}

is undecidable

  • Idea: Proof by contradiction

(1) We assume we have a decider D for ATM (2) Using D, we derive a logical contradiction. Construct another decider D' Show an input Y that D' neither accepts nor rejects So D' cannot be a decider. Contradiction What is Y? (3) We conclude that assumption (1) is false, D cannot exist, and so ATM is undecidable

slide-144
SLIDE 144
  • Theorem: ATM= {(M,w) : M is a TM and M accepts w}

is undecidable

  • Idea: Proof by contradiction

(1) We assume we have a decider D for ATM (2) Using D, we derive a logical contradiction. Construct another decider D' Show an input Y that D' neither accepts nor rejects So D' cannot be a decider. Contradiction Y is D' itself! We run D' on its source code (3) We conclude that assumption (1) is false, D cannot exist, and so ATM is undecidable

slide-145
SLIDE 145
  • Theorem: ATM= {(M,w) : M is a TM and M accepts w}

is undecidable

  • Proof

Assume D decides ATM Build D' := “On input M: Run D(M,M). If it accepts, REJECT If if rejects, ACCEPT.” D' is a decider because ????

slide-146
SLIDE 146
  • Theorem: ATM= {(M,w) : M is a TM and M accepts w}

is undecidable

  • Proof

Assume D decides ATM Build D' := “On input M: Run D(M,M). If it accepts, REJECT If if rejects, ACCEPT.” D' is a decider because D is. However: D' accepts D' ⇨???

slide-147
SLIDE 147
  • Theorem: ATM= {(M,w) : M is a TM and M accepts w}

is undecidable

  • Proof

Assume D decides ATM Build D' := “On input M: Run D(M,M). If it accepts, REJECT If if rejects, ACCEPT.” D' is a decider because D is. However: D' accepts D' D(D',D') rejects ⇨ ⇨???

slide-148
SLIDE 148
  • Theorem: ATM= {(M,w) : M is a TM and M accepts w}

is undecidable

  • Proof

Assume D decides ATM Build D' := “On input M: Run D(M,M). If it accepts, REJECT If if rejects, ACCEPT.” D' is a decider because D is. However: D' accepts D' D(D',D') rejects D' ⇨ ⇨ rejects D' D' rejects D' ⇨???

slide-149
SLIDE 149
  • Theorem: ATM= {(M,w) : M is a TM and M accepts w}

is undecidable

  • Proof

Assume D decides ATM Build D' := “On input M: Run D(M,M). If it accepts, REJECT If if rejects, ACCEPT.” D' is a decider because D is. However: D' accepts D' D(D',D') rejects D' ⇨ ⇨ rejects D' D' rejects D' D(D',D') accepts ⇨ ⇨???

slide-150
SLIDE 150
  • Theorem: ATM= {(M,w) : M is a TM and M accepts w}

is undecidable

  • Proof

Assume D decides ATM Build D' := “On input M: Run D(M,M). If it accepts, REJECT If if rejects, ACCEPT.” D' is a decider because D is. However: D' accepts D' D(D',D') rejects D' ⇨ ⇨ rejects D' D' rejects D' D(D',D') accepts D' ⇨ ⇨ accepts D' A contradiction either way. So D cannot exist.

slide-151
SLIDE 151
  • Theorem: ATM= {(M,w) : M is a TM and M accepts w}

is undecidable

  • To prove some other language L undecidable, show

L decidable ⇨ ATM decidable This is sufficient by theorem above and contrapositive

  • Such an implication is called a reduction of ATM to L
slide-152
SLIDE 152
  • Theorem: H = {(M,w) : M is a TM and M halts on w}

is undecidable

  • Interpretation: You have a piece of JAVA code that

you are not sure if it works or if it is going to crash (crash = loop forever, freeze, get stuck, etc.)

  • Nobody, by looking at the code, can tell!

H is undecidable

slide-153
SLIDE 153
  • Theorem: H = {(M,w) : M is a TM and M halts on w}

is undecidable

  • Proof:

Suppose D decides H. We build D' that decides ATM D' := “On input (M,w): Run D(M,w) If it rejects, REJECT Otherwise, run M on w until it halts If M accepts, ACCEPT If M rejects, REJECT.”

  • D' accepts (M,w)

M does not reject nor freeze on w  Done

slide-154
SLIDE 154
  • Theorem: L = {M : M is a TM and M accepts 001}

is undecidable

  • Proof:

First, for a TM M and an input w, we define M'w as := “On input x, If x ≠ 001, ACCEPT Otherwise, run M on w, if it accepts, ACCEPT if it rejects, REJECT.”

  • Note: M'w accepts 001

 ?

slide-155
SLIDE 155
  • Theorem: L = {M : M is a TM and M accepts 001}

is undecidable

  • Proof:

First, for a TM M and an input w, we define M'w as := “On input x, If x ≠ 001, ACCEPT Otherwise, run M on w, if it accepts, ACCEPT if it rejects, REJECT.”

  • Note: M'w accepts 001

M accepts w 

slide-156
SLIDE 156
  • Theorem: L = {M : M is a TM and M accepts 001}

is undecidable

  • Proof:

Suppose D decides L. We build D' that decides ATM D' := “On input (M,w): Build M'w and Run D(M'w) If it accepts, ACCEPT If it rejects, REJECT.”

  • D' accepts (M,w)

 ?

slide-157
SLIDE 157
  • Theorem: L = {M : M is a TM and M accepts 001}

is undecidable

  • Proof:

Suppose D decides L. We build D' that decides ATM D' := “On input (M,w): Build M'w and Run D(M'w) If it accepts, ACCEPT If it rejects, REJECT.”

  • D' accepts (M,w)

D accepts  M'w  ?

slide-158
SLIDE 158
  • Theorem: L = {M : M is a TM and M accepts 001}

is undecidable

  • Proof:

Suppose D decides L. We build D' that decides ATM D' := “On input (M,w): Build M'w and Run D(M'w) If it accepts, ACCEPT If it rejects, REJECT.”

  • D' accepts (M,w)

D accepts  M'w  M'w accepts 001  ?

slide-159
SLIDE 159
  • Theorem: L = {M : M is a TM and M accepts 001}

is undecidable

  • Proof:

Suppose D decides L. We build D' that decides ATM D' := “On input (M,w): Build M'w and Run D(M'w) If it accepts, ACCEPT If it rejects, REJECT.”

  • D' accepts (M,w)

D accepts  M'w  M'w accepts 001 M accepts w Done 

slide-160
SLIDE 160
  • What about

{(M,w) : M is a TM and L(M) is finite L(M) = Ø |L(M)| = 56 or 127 ....

  • All undecidable
  • TM are so powerful that you

cannot decide anything about what they do!

slide-161
SLIDE 161
  • The undecidability proofs seen so far

have not used anything specific about TM. Same proofs work with JAVA instead of TM

  • TM are more useful than JAVA in pinpointing

the simplest languages that are undecidable

  • We now give a few examples
slide-162
SLIDE 162
  • { D : D is a DFA and L(D) = ∑ * }

Decidable?

  • { G : G is CFG and L(G) = ∑ * }
slide-163
SLIDE 163
  • { D : D is a DFA and L(D) = ∑ * }

Decidable? Yes How?

  • { G : G is CFG and L(G) = ∑ * }
slide-164
SLIDE 164
  • { D : D is a DFA and L(D) = ∑ * }

Decidable? Yes How? Check if every state reachable from start state is accept

  • { G : G is CFG and L(G) = ∑ * }

Decidable?

slide-165
SLIDE 165
  • { D : D is a DFA and L(D) = ∑ * }

Decidable? Yes How? Check if every state reachable from start state is accept

  • { G : G is CFG and L(G) = ∑ * }

Decidable? No Why?

slide-166
SLIDE 166
  • { D : D is a DFA and L(D) = ∑ * }

Decidable? Yes How? Check if every state reachable from start state is accept

  • { G : G is CFG and L(G) = ∑ * }

Decidable? No Why? Can use it to decide ATM, which is undecidable Idea: simulate TM via CFG Would be much more complicated with JAVA

slide-167
SLIDE 167
  • Theorem: L:={G: G is CFG and L(G)=∑*} undecidable
  • Proof: Suppose D decides L
  • We construct D' that decides ATM:
  • D' := “On input (M,w):

construct CFG G : L(G) ≠ ∑* M accepts w  run D on G if it accepts, REJECT if it rejects, ACCEPT”

  • Key of proof is construction of G
slide-168
SLIDE 168
  • Given (M,w) want G: L(G) ≠ ∑*

M accepts w 

  • We construct G : L(G) = all strings that are NOT

accepting computations of M on w

  • Represent computation by sequence of

configurations separated by #: C1#C2#C3 ...

  • Example: q0000101#1q300101#10q20101
slide-169
SLIDE 169
  • Construct G: L(G) = all strings over Δ = {#} U Γ U Q

that are NOT accepting computations of M on w

  • A string C1#C2#C3#...#Ck is in L(G) 

(a) C1 is not the start configuration, or (b) Ck is not an accept configuration, or (c) i : C ∃

i does not yield Ci+1

  • We construct CFG for (a), (b), and (c) separately

then use closure under U

slide-170
SLIDE 170
  • (a) CFG Ga : L(Ga) = strings C1#C2#C3#...#Ck

such that C1 is not the start configuration

  • Recall start configuration is q0w
  • Consider Regular Expression R = q0w # Δ*

L(R) = strings starting with (start configuration)#

  • not L(R) is regular, hence context-free
  • All these transformations can be performed by TM
slide-171
SLIDE 171
  • (b) CFG Gb : L(Gb) = strings C1#C2#C3#...#Ck

such that Ck is not an accept configuration

  • Consider RE R = Δ* qaccept (Δ-{#})*

L(R) = strings where Ck contains accept state

  • not L(R) is regular, hence context-free
  • All these transformations can be performed by TM
slide-172
SLIDE 172
  • (c) CFG Gc : L(Gc) = strings C1#C2#C3#...#Ck

such that i : C ∃

i does not yield Ci+1

  • Here we: use power of CFG, and

exploit locality of TM computation

  • Technical detail: we show i : C

i does not yield Ci+1R

  • Write TM computation as: C1#C2R#C3#C4R#...
slide-173
SLIDE 173
  • (c) CFG Gc : L(Gc) = strings C1#C2#C3#...#Ck

such that i : C ∃

i does not yield Ci+1R

  • Next is the idea; there are a few details to be filled in
  • Construct Gc : L(Gc) = Δ* abc (Δ-{#})

t # (Δ-{#}) t fed Δ*

for any t ≥ 0, any 6 symbols a b c d e f that are inconsistent with TM transition function δ

  • Note: Essentially this is CFG for w#wR seen before
slide-174
SLIDE 174
  • Recap:
  • Theorem: L:={G: G is CFG and L(G)=∑*} undecidable
  • Key of proof is, on input (M,w), construct CFG G :

L(G) = all strings that are NOT accepting computations of M on w

  • Use locality of TM computation (easier than JAVA)
  • Conceptually simple, but a few details
slide-175
SLIDE 175
  • Theorem: ECF={(G,G'): G, G' CFG and L(G) = L(G') }

undecidable

  • Meaning: You think you have a 5-line grammar that is

equivalent to another 5000-page grammar

  • Nobody can tell if they are indeed equivalent
slide-176
SLIDE 176
  • Theorem: ECF={(G,G'): G, G' CFG and L(G) = L(G') }

undecidable

  • Proof: Suppose D decides ECF

We construct D' that decides {G: G CFG, L(G)=∑* } D' := “On input G: Build CFG G' = S → ε | Sa a ∑ ∀ ∈ Run D(G,G') If it accepts, ACCEPT If it rejects, REJECT.”

  • L(G') = ∑*, so D' accepts G

L(G) = L(G') = ∑ * 

slide-177
SLIDE 177
  • Undecidability in logic
  • Consider sentences over = {1,2,3,...}

ℕ using variables x, y, z

  • perations +, multiplication,

equality = connectives Λ V quantifiers , ∃ ∀

  • Example: x > 1 y > 1 : 5039 = xy

∃ ∃ Meaning: ?

slide-178
SLIDE 178
  • Undecidability in logic
  • Consider sentences over = {1,2,3,...}

ℕ using variables x, y, z

  • perations +, multiplication,

equality = connectives Λ V quantifiers , ∃ ∀

  • Example: x > 1 y > 1 : 5039 = xy

∃ ∃ Meaning: 5039 is not prime (a false sentence)

slide-179
SLIDE 179
  • ∀q p > q not ( x > 1 y > 1 : p = xy)

∃ ∃ ∃ There are infinitely many primes Proved by Euclid ~ 2300 years ago

  • ∀a b c n > 2, a

∀ ∀ ∀

n + bn ≠ cn

Fermat's last theorem, stated in 1637 Proved by Andrew Wiles in 1995 (358 years later)

  • ∀q p > q not ( x > 1 y > 1 : p = xy V p+2 =xy)

∃ ∃ ∃ Twin prime conjecture

slide-180
SLIDE 180
  • Theorem [Godel, Church]

TRUTH = { S : S is a true sentence over } ℕ is undecidable

  • Proof sketch:

Given TM M and input w, build a formula SM,w such that: SM,w true M accepts w  use integers to encode configurations of TM

  • Note: without multiplication, TRUTH is decidable
slide-181
SLIDE 181
  • Undecidability in mathematics

Polynomials: p(x,y,z) = x2 + 56 y + 13xy3z

  • H10 = { p(x1, ..., xn) : p(x1, ..., xn) is a polynomial and

and a ∃ 1, ..., an such that p(a ∈ℕ

1, ..., an) = 0}

  • Hilbert asked for a “decider” for H10 in 1900
  • Theorem [Matiyasevich, 1970] H10 is undecidable