Turing Machines 1 The Language Hierarchy ContextFree Languages

  • Slides: 46
Download presentation
Turing Machines 1

Turing Machines 1

The Language Hierarchy ? ? Context-Free Languages Regular Languages 2

The Language Hierarchy ? ? Context-Free Languages Regular Languages 2

Languages accepted by Turing Machines Context-Free Languages Regular Languages 3

Languages accepted by Turing Machines Context-Free Languages Regular Languages 3

Tape. . . A Turing Machine. . . Read-Write head Control Unit 4

Tape. . . A Turing Machine. . . Read-Write head Control Unit 4

The Tape No boundaries -- infinite length. . . Read-Write head The head moves

The Tape No boundaries -- infinite length. . . Read-Write head The head moves Left or Right 5

. . . Read-Write head The head at each time step: 1. Reads a

. . . Read-Write head The head at each time step: 1. Reads a symbol 2. Writes a symbol 3. Moves Left or Right 6

Example: . . . Time 0 Time 1 . . . 1. Reads 2.

Example: . . . Time 0 Time 1 . . . 1. Reads 2. Writes 3. Moves Left 7

. . . Time 1 Time 2 . . . 1. Reads 2. Writes

. . . Time 1 Time 2 . . . 1. Reads 2. Writes 3. Moves Right 8

The Input String Input string Blank symbol . . . head Head starts at

The Input String Input string Blank symbol . . . head Head starts at the leftmost position of the input string 9

Input string. . . Blank symbol. . . head Remark: the input string is

Input string. . . Blank symbol. . . head Remark: the input string is never empty 10

States & Transitions Read Write Move Left Move Right 11

States & Transitions Read Write Move Left Move Right 11

Example: Time 1. . . current state 12

Example: Time 1. . . current state 12

. . . Time 1 Time 2 . . . 13

. . . Time 1 Time 2 . . . 13

Example: . . . Time 1 Time 2 . . . 14

Example: . . . Time 1 Time 2 . . . 14

Example: . . . Time 1 Time 2 . . . 15

Example: . . . Time 1 Time 2 . . . 15

Determinism Turing Machines are deterministic Allowed Not Allowed No lambda transitions allowed 16

Determinism Turing Machines are deterministic Allowed Not Allowed No lambda transitions allowed 16

Partial Transition Function Example: . . . Allowed: No transition for input symbol 17

Partial Transition Function Example: . . . Allowed: No transition for input symbol 17

Halting The machine halts if there are no possible transitions to follow 18

Halting The machine halts if there are no possible transitions to follow 18

Example: . . . No possible transition HALT!!! 19

Example: . . . No possible transition HALT!!! 19

Final States Allowed Not Allowed • Final states have no outgoing transitions • In

Final States Allowed Not Allowed • Final states have no outgoing transitions • In a final state the machine halts 20

Acceptance Accept Input If machine halts in a final state Reject Input If machine

Acceptance Accept Input If machine halts in a final state Reject Input If machine halts in a non-final state or If machine enters an infinite loop 21

Turing Machine Example A Turing machine that accepts the language: 22

Turing Machine Example A Turing machine that accepts the language: 22

Time 0 23

Time 0 23

Time 1 24

Time 1 24

Time 2 25

Time 2 25

Time 3 26

Time 3 26

Time 4 Halt & Accept 27

Time 4 Halt & Accept 27

Rejection Example Time 0 28

Rejection Example Time 0 28

Time 1 No possible Transition Halt & Reject 29

Time 1 No possible Transition Halt & Reject 29

Infinite Loop Example A Turing machine for language 30

Infinite Loop Example A Turing machine for language 30

Time 0 31

Time 0 31

Time 1 32

Time 1 32

Time 2 33

Time 2 33

Time 2 Time 4 Infinite loop Time 3 Time 5 34

Time 2 Time 4 Infinite loop Time 3 Time 5 34

Because of the infinite loop: • The final state cannot be reached • The

Because of the infinite loop: • The final state cannot be reached • The machine never halts • The input is not accepted 35

Formal Definitions for Turing Machines 36

Formal Definitions for Turing Machines 36

Transition Function 37

Transition Function 37

Transition Function 38

Transition Function 38

Turing Machine: States Input alphabet Tape alphabet Transition function Initial state Final states blank

Turing Machine: States Input alphabet Tape alphabet Transition function Initial state Final states blank 39

Configuration Instantaneous description: 40

Configuration Instantaneous description: 40

Time 4 Time 5 A Move: 41

Time 4 Time 5 A Move: 41

Time 4 Time 5 Time 6 Time 7 42

Time 4 Time 5 Time 6 Time 7 42

Equivalent notation: 43

Equivalent notation: 43

Initial configuration: Input string 44

Initial configuration: Input string 44

The Accepted Language For any Turing Machine Initial state Final state 45

The Accepted Language For any Turing Machine Initial state Final state 45

Standard Turing Machine The machine we described is the standard: • Deterministic • Infinite

Standard Turing Machine The machine we described is the standard: • Deterministic • Infinite tape in both directions • Tape is the input/output file 46