Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 12 Mälardalen University 2007.

Similar presentations


Presentation on theme: "1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 12 Mälardalen University 2007."— Presentation transcript:

1 1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 12 Mälardalen University 2007

2 2 Content Chomsky Language Hierarchy Turing Machines Determinism Halting TM Examples Standard TM Computing Functions with TM Combining TMs Turing Thesis

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

4 4 Regular Languages Context-free languages Unrestricted grammar languages

5 5 FA Push-down Automata Languages accepted by Turing Machines

6 6

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

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

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

10 10 Example Time 0...... Time 1...... 1. Reads a 2. Writes k 3. Moves left

11 11 Time 1...... Time 2...... 1. Reads b 2. Writes f 3. Moves Right

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

13 13 Read Write Move Left Move Right States & Transitions

14 14 Example...... Time 1 current state

15 15...... Time 1...... Time 2

16 16...... Time 1...... Time 2 Example

17 17...... Time 1...... Time 2 Example

18 18 Determinism Allowed Not Allowed No lambda transitions allowed in TM! Turing Machines are deterministic

19 19 Partial Transition Function...... Example No transition for input symbol Allowed

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

21 21 Example...... No possible transition HALT!

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

23 23 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

24 24 Turing Machine Example A TM that accepts the language

25 25 Time 0

26 26 Time 1

27 27 Time 2

28 28 Time 3

29 29 Time 4 Halt & Accept

30 30 Rejection Example Time 0

31 31 Time 1 No possible Transition Halt & Reject

32 32 Infinite Loop Example Another TM for language

33 33 Time 0

34 34 Time 1

35 35 Time 2

36 36 Time 2 Time 3 Time 4 Time 5... infinite loop…

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

38 38 Another Turing Machine Example Turing machine for the language

39 39 Time 0

40 40 Time 1

41 41 Time 2

42 42 Time 3

43 43 Time 4

44 44 Time 5

45 45 Time 6

46 46 Time 7

47 47 Time 8

48 48 Time 9

49 49 Time 10

50 50 Time 11

51 51 Time 12

52 52 Halt & Accept Time 13

53 53 If we modify the machine for the language we can easily construct a machine for the language Observation

54 54 Formal Definitions for Turing Machines

55 55 Transition Function

56 56 Transition Function

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

58 58 Instantaneous description: Configuration

59 59 Time 4Time 5 A move:

60 60 Time 4Time 5 Time 6Time 7

61 61 Equivalent notation:

62 62 Initial configuration: Input string

63 63 For any Turing Machine Initial stateFinal state The Accepted Language

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

65 65 Computing Functions with Turing Machines

66 66 A function has: Domain (domän): Range (värdemängd):

67 67 A function may have many parameters: Example: Addition function

68 68 Integer Domain Binary:101 Decimal:5 We prefer unary representation: easier to manipulate Unary:11111

69 69 Definition A function is computable if there is a Turing Machine such that: Initial configuration Final configuration Domain final state initial state For all

70 70 Initial Configuration Final Configuration In other words Domain For all A function is computable if there is a Turing Machine such that

71 71 Example (Addition) The function is computable Turing Machine: Input string: unary Output string: unary are integers

72 72 Start Finish final state initial state

73 73 Turing machine for function

74 74 Execution Example: Time 0 Final Result (2)

75 75 Time 0

76 76 Time 1

77 77 Time 2

78 78 Time 3

79 79 Time 4

80 80 Time 5

81 81 Time 6

82 82 Time 7

83 83 Time 8

84 84 Time 9

85 85 Time 10

86 86 Time 11

87 87 HALT & accept Time 12

88 88 Another Example (Multiplication) The functionis computable Turing Machine Input string: unary Output string:unary is integer

89 89 Start Finish final state initial state

90 90 Turing Machine Pseudocode for Replace every 1 with $ Repeat: Find rightmost $, replace it with 1 Go to right end, insert 1 Until no more $ remain

91 91 Turing Machine for

92 92 Start Finish

93 93 Time 0

94 94 Time 1

95 95 Time 2

96 96 Time 3

97 97 Time 4

98 98 Time 5

99 99 Time 6

100 100 Time 7

101 101 Time 8

102 102 Time 9

103 103 Time 10

104 104 Time 11

105 105 Time 12

106 106 Time 13

107 107 Time 14

108 108 Another Example The function is computable if Turing Machine for Output: or Input:

109 109 Turing Machine Pseudocode Match a 1 from with a 1 from Repeat Until all of or are matched If a 1 from is not matched erase tape, write 1 else erase tape, write 0

110 110 Combining Turing Machines

111 111 Block Diagram Turing Machine inputoutput

112 112 Example if Comparer Adder Eraser

113 113 Turing’s Thesis

114 114 Do Turing machines have the same power with a digital computer? Intuitive answer: Yes There is no formal answer! Question:

115 115 Turing’s thesis Any computation carried out by mechanical means can be performed by a Turing Machine (1930)

116 116 Computer Science Law A computation is mechanical if and only if it can be performed by a Turing Machine There is no known model of computation more powerful than Turing Machines

117 117 Definition of Algorithm An algorithm for function f(w) is a Turing Machine which computes f(w)

118 118 When we say There exists an algorithm Algorithms are Turing Machines It means There exists a Turing Machine

119 119 LanguageGrammarMachine Chomsky Hierarchy Turing non- computable Natural computing?? Recursively enumerable (RE) UnrestrictedTuring machines 0 Recursive Turing machines that always halt 0 Context-sensitive Context-sensitive grammar Linear-bounded automata 1 Context-free Context-free grammar Non-deterministic pushdown automata 2 Regular Regular expressions Finite state automata 3 properly inclusive Languages, Grammars, Machines

120 120 Regular Languages FINITE AUTOMATA Context-free languages PUSH-DOWN AUTOMATA Unrestricted grammar languages TURING MACHINES


Download ppt "1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 12 Mälardalen University 2007."

Similar presentations


Ads by Google