Presentation is loading. Please wait.

Presentation is loading. Please wait.

Fall 2004COMP 3351 Turing Machines. Fall 2004COMP 3352 The Language Hierarchy Regular Languages Context-Free Languages ? ?

Similar presentations


Presentation on theme: "Fall 2004COMP 3351 Turing Machines. Fall 2004COMP 3352 The Language Hierarchy Regular Languages Context-Free Languages ? ?"— Presentation transcript:

1 Fall 2004COMP 3351 Turing Machines

2 Fall 2004COMP 3352 The Language Hierarchy Regular Languages Context-Free Languages ? ?

3 Fall 2004COMP 3353 Regular Languages Context-Free Languages Languages accepted by Turing Machines

4 Fall 2004COMP 3354 A Turing Machine...... Tape Read-Write head Control Unit

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

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

7 Fall 2004COMP 3357...... Example: Time 0...... Time 1 1. Reads 2. Writes 3. Moves Left

8 Fall 2004COMP 3358...... Time 1...... Time 2 1. Reads 2. Writes 3. Moves Right

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

10 Fall 2004COMP 33510...... Blank symbol head Input string Remark: the input string is never empty

11 Fall 2004COMP 33511 States & Transitions Read Write Move Left Move Right

12 Fall 2004COMP 33512 Example:...... Time 1 current state

13 Fall 2004COMP 33513...... Time 1...... Time 2

14 Fall 2004COMP 33514...... Time 1...... Time 2 Example:

15 Fall 2004COMP 33515...... Time 1...... Time 2 Example:

16 Fall 2004COMP 33516 Determinism Allowed Not Allowed No lambda transitions allowed Turing Machines are deterministic

17 Fall 2004COMP 33517 Partial Transition Function...... Example: No transition for input symbol Allowed:

18 Fall 2004COMP 33518 Halting The machine halts if there are no possible transitions to follow

19 Fall 2004COMP 33519 Example:...... No possible transition HALT!!!

20 Fall 2004COMP 33520 Final States Allowed Not Allowed Final states have no outgoing transitions In a final state the machine halts

21 Fall 2004COMP 33521 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

22 Fall 2004COMP 33522 Turing Machine Example A Turing machine that accepts the language:

23 Fall 2004COMP 33523 Time 0

24 Fall 2004COMP 33524 Time 1

25 Fall 2004COMP 33525 Time 2

26 Fall 2004COMP 33526 Time 3

27 Fall 2004COMP 33527 Time 4 Halt & Accept

28 Fall 2004COMP 33528 Rejection Example Time 0

29 Fall 2004COMP 33529 Time 1 No possible Transition Halt & Reject

30 Fall 2004COMP 33530 Infinite Loop Example

31 Fall 2004COMP 33531 Time 0

32 Fall 2004COMP 33532 Time 1

33 Fall 2004COMP 33533 Time 2

34 Fall 2004COMP 33534 Time 2 Time 3 Time 4 Time 5 Infinite loop

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

36 Fall 2004COMP 33536 Another Turing Machine Example Turing machine for the language

37 Fall 2004COMP 33537 Time 0

38 Fall 2004COMP 33538 Time 1

39 Fall 2004COMP 33539 Time 2

40 Fall 2004COMP 33540 Time 3

41 Fall 2004COMP 33541 Time 4

42 Fall 2004COMP 33542 Time 5

43 Fall 2004COMP 33543 Time 6

44 Fall 2004COMP 33544 Time 7

45 Fall 2004COMP 33545 Time 8

46 Fall 2004COMP 33546 Time 9

47 Fall 2004COMP 33547 Time 10

48 Fall 2004COMP 33548 Time 11

49 Fall 2004COMP 33549 Time 12

50 Fall 2004COMP 33550 Halt & Accept Time 13

51 Fall 2004COMP 33551 We easily modify the machine for the language to construct a TM for the language Observation:

52 Fall 2004COMP 33552 Formal Definitions for Turing Machines

53 Fall 2004COMP 33553 Transition Function

54 Fall 2004COMP 33554 Transition Function

55 Fall 2004COMP 33555 Turing Machine: States Input alphabet Tape alphabet Transition function Initial state blank Final states

56 Fall 2004COMP 33556 Configuration Instantaneous description:

57 Fall 2004COMP 33557 Time 4Time 5 A Move:

58 Fall 2004COMP 33558 Time 4Time 5 Time 6Time 7

59 Fall 2004COMP 33559 Equivalent notation:

60 Fall 2004COMP 33560 Initial configuration: Input string

61 Fall 2004COMP 33561 The Accepted Language For any Turing Machine Initial stateFinal state

62 Fall 2004COMP 33562 Standard Turing Machine Deterministic Infinite tape in both directions Tape is the input/output file The machine we described is the standard:

63 Fall 2004COMP 33563 Computing Functions with Turing Machines

64 Fall 2004COMP 33564 A function Domain: Result Region: has:

65 Fall 2004COMP 33565 A function may have several parameters / arguments: Example: The Addition function

66 Fall 2004COMP 33566 Integer Domain Unary: Binary: Decimal: 11111 101 5 We prefer unary representation: easier to manipulate with Turing machines

67 Fall 2004COMP 33567 Definition: A function is computable if there is a Turing Machine such that: Initial configurationFinal configuration Domain final stateinitial state For all

68 Fall 2004COMP 33568 Initial Configuration Final Configuration A function is computable if there is a Turing Machine such that: In other words: (the domain)

69 Fall 2004COMP 33569 Example The function is computable A Turing Machine M for f: Input string: unary Output string: unary are integers

70 Fall 2004COMP 33570 Start initial state The 0 is the delimiter that separates the two numbers

71 Fall 2004COMP 33571 Start Finish final state initial state

72 Fall 2004COMP 33572 Finish final state The 0 helps when we use the result for other operations

73 Fall 2004COMP 33573 Turing machine M for the function:

74 Fall 2004COMP 33574 Execution Example: Input (time 0) Output (final result) (2)

75 Fall 2004COMP 33575 Time 0

76 Fall 2004COMP 33576 Time 1

77 Fall 2004COMP 33577 Time 2

78 Fall 2004COMP 33578 Time 3

79 Fall 2004COMP 33579 Time 4

80 Fall 2004COMP 33580 Time 5

81 Fall 2004COMP 33581 Time 6

82 Fall 2004COMP 33582 Time 7

83 Fall 2004COMP 33583 Time 8

84 Fall 2004COMP 33584 Time 9

85 Fall 2004COMP 33585 Time 10

86 Fall 2004COMP 33586 Time 11

87 Fall 2004COMP 33587 Time 12

88 Fall 2004COMP 33588 HALT & accept Time 13

89 Fall 2004COMP 33589 Another Example The function is computable Turing Machine: Input string: unary Output string:unary is integer

90 Fall 2004COMP 33590 Start Finish final state initial state

91 Fall 2004COMP 33591 Turing Machine Pseudocode for Replace every 1 with $ Repeat: Find rightmost $, replace it with 1 Go to right end, then insert 1 Until no more $ remains

92 Fall 2004COMP 33592 A Turing Machine for:

93 Fall 2004COMP 33593 Example Start Finish

94 Fall 2004COMP 33594 Another Example The function is computable if

95 Fall 2004COMP 33595 A Turing Machine for Input: Output: or if

96 Fall 2004COMP 33596 Pseudocode for our Turing Machine: Match a 1 from with a 1 from Repeat Until all of or is matched If a 1 from is not matched erase tape, then write 1 else erase tape, then write 0

97 Fall 2004COMP 33597 Combining Turing Machines

98 Fall 2004COMP 33598 Block Diagram Turing Machine inputoutput

99 Fall 2004COMP 33599 Example: if Comparer Adder Eraser


Download ppt "Fall 2004COMP 3351 Turing Machines. Fall 2004COMP 3352 The Language Hierarchy Regular Languages Context-Free Languages ? ?"

Similar presentations


Ads by Google