Presentation is loading. Please wait.

Presentation is loading. Please wait.

Recursively Enumerable and Recursive Languages. Definition: A language is recursively enumerable if some Turing machine accepts it.

Similar presentations


Presentation on theme: "Recursively Enumerable and Recursive Languages. Definition: A language is recursively enumerable if some Turing machine accepts it."— Presentation transcript:

1 Recursively Enumerable and Recursive Languages

2 Definition: A language is recursively enumerable if some Turing machine accepts it

3 For string : Let be a recursively enumerable language and the Turing Machine that accepts it ifthen halts in a final state ifthen halts in a non-final state or loops forever

4 Definition: A language is recursive if some Turing machine accepts it and halts on any input string In other words: A language is recursive if there is a membership algorithm for it

5 For string : Let be a recursive language and the Turing Machine that accepts it ifthen halts in a final state ifthen halts in a non-final state

6 We will prove: 1. There is a specific language which is not recursively enumerable (not accepted by any Turing Machine) 2. There is a specific language which is recursively enumerable but not recursive

7 Recursive Recursively Enumerable Non Recursively Enumerable

8 A Language which is not Recursively Enumerable

9 We want to find a language that is not Recursively Enumerable This language is not accepted by any Turing Machine

10 Consider alphabet Strings:

11 Consider Turing Machines that accept languages over alphabet They are countable:

12 Example language accepted by Alternative representation

13

14 Consider the language consists from the 1’s in the diagonal

15

16 Consider the language consists of the 0’s in the diagonal

17

18 Theorem: Language is not recursively enumerable

19 Proof: is recursively enumerable Assume for contradiction that There must exist some machine that accepts

20 Question:

21 Answer:

22 Question:

23 Answer:

24 Question:

25 Answer:

26 Similarly: for any Because either: or

27 Therefore, the machine cannot exist Therefore, the language is not recursively enumerable End of Proof

28 Observation: There is no algorithm that describes (otherwise would be accepted by some Turing Machine)

29 Recursive Recursively Enumerable Non Recursively Enumerable

30 A Language which is Recursively Enumerable and not Recursive

31 We want to find a language which There is a Turing Machine that accepts the language The machine doesn’t halt on some input Is recursively enumerable But not recursive

32 We will prove that the language Is recursively enumerable but not recursive

33

34 The language Theorem: is recursively enumerable

35 Proof: We will give a Turing Machine that accepts

36 Turing Machine that accepts For any input string Compute, for which Find Turing machine (using an enumeration procedure for Turing Machines) Simulate on input If accepts, then accept End of Proof

37 Observation: Recursively enumerable Not recursively enumerable (Thus, also not recursive)

38 Theorem: The language is not recursive

39 Proof: Assume for contradiction that is recursive Then is recursive: Take the Turing Machine that accepts halts on any input: If accepts then reject If rejects then accept

40 Therefore: is recursive But we know: is not recursively enumerable thus, not recursive CONTRADICTION!!!!

41 Therefore, is not recursive End of Proof

42 Recursive Recursively Enumerable Non Recursively Enumerable

43 Turing acceptable languages and Enumeration Procedures

44 We will prove: If a language is recursive then there is an enumeration procedure for it A language is recursively enumerable if and only if there is an enumeration procedure for it (weak result) (strong result)

45 Theorem: if a language is recursive then there is an enumeration procedure for it

46 Proof: Enumeration Machine Accepts Enumerates all strings of input alphabet

47 If the alphabet is then can enumerate strings as follows:

48 Enumeration procedure Repeat: generates a string checks if YES: print to output NO: ignore End of Proof

49 Example: Enumeration Output

50 Theorem: if language is recursively enumerable then there is an enumeration procedure for it

51 Proof: Enumeration Machine Accepts Enumerates all strings of input alphabet

52 If the alphabet is then can enumerate strings as follows:

53 Enumeration procedure Repeat:generates a string checks if YES: print to output NO: ignore NAIVE APPROACH Problem: If machine may loop forever

54 executes first step on BETTER APPROACH Generates second string executes first step on second step on Generates first string

55 Generates third string executes first step on second step on third step on And so on............

56 1 Step in string 111 22 22 3333

57 If for any string machine halts in a final state then it prints on the output End of Proof

58 Theorem: If for language there is an enumeration procedure then is recursively enumerable

59 Proof: Input Tape Enumerator for Compare Machine that accepts

60 Turing machine that accepts Repeat: Using the enumerator, generate the next string of For input string Compare generated string with If same, accept and exit loop End of Proof

61 We have proven: A language is recursively enumerable if and only if there is an enumeration procedure for it

62 The Chomsky Hierarchy

63 Non-recursively enumerable Recursively-enumerable Recursive Context-sensitive Context-free Regular The Chomsky Hierarchy

64 Decidability

65 Consider problems with answer YES or NO Examples: Does Machine have three states ? Is string a binary number? Does DFA accept any input?

66 A problem is decidable if some Turing machine decides (solves) the problem Decidable problems: Does Machine have three states ? Is string a binary number? Does DFA accept any input?

67 Turing Machine Input problem instance YES NO The Turing machine that decides (solves) a problem answers YES or NO for each instance of the problem

68 The machine that decides (solves) a problem: If the answer is YES then halts in a yes state If the answer is NO then halts in a no state These states may not be final states

69 YES states NO states Turing Machine that decides a problem YES and NO states are halting states

70 Difference between Recursive Languages and Decidable problems The YES states may not be final states For decidable problems:

71 Some problems are undecidable: which means: there is no Turing Machine that solves all instances of the problem A simple undecidable problem: The membership problem

72 The Membership Problem Input:Turing Machine String Question: Does accept ?

73 Theorem: The membership problem is undecidable Proof:Assume for contradiction that the membership problem is decidable (there are and for which we cannot decide whether )

74 Thus, there exists a Turing Machine that solves the membership problem YES accepts NO rejects

75 Let be a recursively enumerable language Let be the Turing Machine that accepts We will prove that is also recursive: we will describe a Turing machine that accepts and halts on any input

76 accepts ? NO YES accept Turing Machine that accepts and halts on any input reject

77 Therefore,is recursive But there are recursively enumerable languages which are not recursive Contradiction!!!! Since is chosen arbitrarily, every recursively enumerable language is also recursive

78 Therefore, the membership problem is undecidable END OF PROOF

79 Another famous undecidable problem: The halting problem

80 The Halting Problem Input:Turing Machine String Question: Does halt on input ?

81 Theorem: The halting problem is undecidable Proof:Assume for contradiction that the halting problem is decidable (there are and for which we cannot decide whether halts on input )

82 Thus, there exists Turing Machine that solves the halting problem YEShalts on doesn’t halt on NO

83 Input: initial tape contents Encoding of String YES NO Construction of

84 Construct machine : If returns YES then loop forever If returns NO then halt

85 NO Loop forever YES

86 Construct machine : Input: If halts on input Then loop forever Else halt (machine )

87 copy

88 Run machine with input itself: Input: If halts on input Then loop forever Else halt (machine )

89 on input If halts then loops forever If doesn’t halt then it halts : NONSENSE !!!!!

90 Therefore, we have contradiction The halting problem is undecidable END OF PROOF

91 Another proof of the same theorem: If the halting problem was decidable then every recursively enumerable language would be recursive

92 Theorem: The halting problem is undecidable Proof:Assume for contradiction that the halting problem is decidable

93 There exists Turing Machine that solves the halting problem YEShalts on doesn’t halt on NO

94 Let be a recursively enumerable language Let be the Turing Machine that accepts We will prove that is also recursive: we will describe a Turing machine that accepts and halts on any input

95 halts on ? YES NO Run with input reject accept reject Turing Machine that accepts and halts on any input Halts on final state Halts on non-final state

96 Thereforeis recursive But there are recursively enumerable languages which are not recursive Contradiction!!!! Since is chosen arbitrarily, every recursively enumerable language is also recursive

97 Therefore, the halting problem is undecidable END OF PROOF

98 Reducibility

99 Problem is reduced to problem If we can solve problem then we can solve problem

100 If is undecidable then is undecidable If is decidable then is decidable Problem is reduced to problem

101 Example: the halting problem is reduced to the state-entry problem

102 The state-entry problem Inputs: Turing Machine State Question: Does String enter state on input ?

103 Theorem: The state-entry problem is undecidable Proof: Reduce the halting problem to the state-entry problem

104 state-entry problem decider YES NO enters doesn’t enter Suppose we have a Decider for the state-entry algorithm:

105 Halting problem decider YES NO halts on doesn’t halt on We want to build a decider for the halting problem:

106 State-entry problem decider Halting problem decider YES NO YES NO We want to reduce the halting problem to the state-entry problem:

107 Halting problem decider YES NO YES NO Convert Inputs ? We need to convert one problem instance to the other problem instance State-entry problem decider

108 Convert to : Add new state From any halting state of add transitions to halting states Single halt state

109 halts on input halts on state on input if and only if

110 Generate Halting problem decider YES NO YES NO State-entry problem decider

111 Since the halting problem is undecidable, the state-entry problem is undecidable END OF PROOF We reduced the halting problem to the state-entry problem

112 Another example: the halting problem is reduced to the blank-tape halting problem

113 The blank-tape halting problem Input:Turing Machine Question:Doeshalt when started with a blank tape?

114 Theorem: Proof: Reduce the halting problem to the blank-tape halting problem The blank-tape halting problem is undecidable

115 blank-tape halting problem decider YES NO halts on blank tape doesn’t halt on blank tape Suppose we have a decider for the blank-tape halting problem:

116 halting problem decider YES NO halts on doesn’t halt on We want to build a decider for the halting problem:

117 Blank-tape halting problem decider Halting problem decider YES NO YES NO We want to reduce the halting problem to the blank-tape halting problem:

118 Blank-tape halting problem decider Halting problem decider YES NO YES NO We need to convert one problem instance to the other problem instance Convert Inputs ?

119 Construct a new machine When started on blank tape, writes Then continues execution like then write step 1step2 if blank tapeexecute with input

120 halts on input string halts when started with blank tape if and only if

121 Generate blank-tape halting problem decider Halting problem decider YES NO YES NO

122 Since the halting problem is undecidable, the blank-tape halting problem is undecidable END OF PROOF We reduced the halting problem to the blank-tape halting problem

123 Does machine halt on input ? Summary of Undecidable Problems Halting Problem: Membership problem: Does machine accept string ?

124 Does machine enter state on input ? Does machine halt when starting on blank tape? Blank-tape halting problem: State-entry Problem:

125 Uncomputable Functions

126 A function is uncomputable if it cannot be computed for all of its domain Domain Values region

127 An uncomputable function: maximum number of moves until any Turing machine with states halts when started with the blank tape

128 Theorem:Function is uncomputable Proof: Then the blank-tape halting problem is decidable Assume for contradiction that is computable

129 Decider for blank-tape halting problem: Input: machine 1. Count states of : 2. Compute 3. Simulate for steps starting with empty tape If halts then return YES otherwise return NO

130 Therefore, the blank-tape halting problem is decidable However, the blank-tape halting problem is undecidable Contradiction!!!

131 Therefore, function in uncomputable END OF PROOF

132 Undecidable Problems for Recursively Enumerable Languages

133 is empty? is finite? contains two different strings of the same length? Take a recursively enumerable language Decision problems: All these problems are undecidable

134 Theorem: For any recursively enumerable language it is undecidable to determine whether is empty Proof: We will reduce the membership problem to this problem

135 empty language problem decider YES NO Suppose we have a decider for the empty language problem: Let be the TM with empty not empty

136 membership problem decider YES NO accepts rejects We will build the decider for the membership problem:

137 YES NO YES Membership problem decider empty language problem decider We want to reduce the membership problem to the empty language problem:

138 YES NO YES Membership problem decider empty language problem decider We need to convert one problem instance to the other problem instance Convert inputs ?

139 Construct machine : When enters a final state, compare with Accept only if executes the same as with On arbitrary input string

140 is not empty if and only if

141 construct YES NO YES Membership problem decider END OF PROOF empty language problem decider

142 Undecidable problems for Recursively enumerable languages continued…

143 is empty? is finite? contains two different strings of the same length? Take a recursively enumerable language Decision problems: All these problems are undecidable

144 Theorem: For a recursively enumerable language it is undecidable to determine whether is finite Proof: We will reduce the halting problem to this problem

145 finite language problem decider YES NO Suppose we have a decider for the finite language problem: Let be the TM with finite not finite

146 Halting problem decider YES NO halts on We will build a decider for the halting problem: doesn’t halt on

147 YES NO YES Halting problem decider finite language problem decider We want to reduce the halting problem to the finite language problem

148 YES NO YES Halting problem decider finite language problem decider We need to convert one problem instance to the other problem instance convert input ?

149 Construct machine : If enters a halt state, accept ( inifinite language) Initially, simulates on input Otherwise, reject ( finite language) On arbitrary input string

150 halts on is infinite if and only if

151 construct YES NO YES halting problem decider finite language problem decider

152 is empty? is finite? contains two different strings of the same length? Take a recursively enumerable language Decision problems: All these problems are undecidable

153 Theorem: For a recursively enumerable language it is undecidable to determine whether contains two different strings of same length Proof: We will reduce the halting problem to this problem

154 Two-strings problem decider YES NO Suppose we have the decider for the two-strings problem: Let be the TM with contains Doesn’t contain two equal length strings

155 Halting problem decider YES NO halts on We will build a decider for the halting problem: doesn’t halt on

156 YES NO YES NO Halting problem decider Two-strings problem decider We want to reduce the halting problem to the empty language problem

157 YES NO YES NO Halting problem decider Two-strings problem decider We need to convert one problem instance to the other problem instance convert inputs ?

158 Construct machine : When enters a halt state, accept if or Initially, simulate on input (two equal length strings ) On arbitrary input string Otherwise, reject ( )

159 halts on if and only if accepts two equal length strings accepts and

160 construct YES NO YES NO Halting problem decider Two-strings problem decider

161 Rice’s Theorem

162 Non-trivial properties of recursively enumerable languages: any property possessed by some (not all) recursively enumerable languages Definition:

163 Some non-trivial properties of recursively enumerable languages: is empty is finite contains two different strings of the same length

164 Rice’s Theorem: Any non-trivial property of a recursively enumerable language is undecidable

165 The Post Correspondence Problem

166 Some undecidable problems for context-free languages: Is context-free grammar ambiguous? Is ? are context-free grammars

167 We need a tool to prove that the previous problems for context-free languages are undecidable: The Post Correspondence Problem

168 Input: Two sequences of strings

169 There is a Post Correspondence Solution if there is a sequence such that: PC-solution: Indices may be repeated or omitted

170 Example: PC-solution:

171 Example: There is no solution Because total length of strings from is smaller than total length of strings from

172 1. The MPC problem is undecidable 2. The PC problem is undecidable (by reducing MPC to PC) (by reducing the membership to MPC) We will show:

173 Theorem: The PC problem is undecidable Proof: We will reduce the MPC problem to the PC problem

174 Some undecidable problems for context-free languages: Is context-free grammar ambiguous? Is ? are context-free grammars We reduce the PC problem to these problems

175 Theorem: Proof: Let be context-free grammars. It is undecidable to determine if Rdeduce the PC problem to this problem

176 Suppose we have a decider for the empty-intersection problem Empty- interection problem decider YES NO Context-free grammars

177 For a context-free grammar, Theorem: it is undecidable to determine if G is ambiguous Proof: Reduce the PC problem to this problem


Download ppt "Recursively Enumerable and Recursive Languages. Definition: A language is recursively enumerable if some Turing machine accepts it."

Similar presentations


Ads by Google