Session 33-34-38
Session 33-34-38
RECURSIVELY ENUMERABLE
AND RECURSIVE LANGUAGE
Session – 33-34-38
INSTRUCTIONAL OBJECTIVES
LEARNING OUTCOMES
A. Senthil - Professor/CSE 3
CREATED BY K. VICTOR BABU
Definition:
A language is recursively enumerable
if some Turing machine accepts it
A. Senthil - Professor/CSE 4
CREATED BY K. VICTOR BABU
Let L be a recursively enumerable language
and M the Turing Machine that accepts it
For string w:
if w L then M halts in a final state
In other words:
A language is recursive if there is
a membership algorithm for it
A. Senthil - 6
CREATED BY K. VICTOR BABU
Let L be a recursive language
and M the Turing Machine that accepts it
For string w:
A. Senthil - Professor/CSE 8
CREATED BY K. VICTOR BABU
A function f (w) has:
f (w)
w D f ( w) S
A. Senthil - Professor/CSE 9
CREATED BY K. VICTOR BABU
A function may have many parameters:
f ( x, y ) x y
A. Senthil - Professor/CSE 10
CREATED BY K. VICTOR BABU
Integer Domain
Decimal: 5
Binary: 101
Unary: 11111
A function f is computable if
there is a Turing Machine M such that:
q0 w q f f ( w)
Initial Final
Configuration Configuration
x, y are integers
Turing Machine:
Start 1 1 1 0 1 1
q0
initial state
A. Senthil - Professor/CSE 15
CREATED BY K. VICTOR BABU
x y
Start 1 1 1 0 1 1
q0 initial state
x y
Finish 1 1 1 1 0
q f final state
A. Senthil - Professor/CSE 16
CREATED BY K. VICTOR BABU
The 0 helps when we use
the result for other operations
x y
Finish 1 1 1 1 0
q f final state
A. Senthil - Professor/CSE 17
CREATED BY K. VICTOR BABU
Turing machine for function f ( x, y ) x y
1 1, R 1 1, R 1 1, L
q0 0 1, R q1 , L q2
1 0, L q3
, R
A. Senthil - Professor/CSE
q4 18
CREATED BY K. VICTOR BABU
Execution Example: Time 0
x y
x 11 (2)
1 1 0 1 1
y 11 (2) q0
Final Result
x y
1 1 1 1 0
q4
A. Senthil - Professor/CSE 19
CREATED BY K. VICTOR BABU
Time 0 1 1 0 1 1
q0
1 1, R 1 1, R 1 1, L
q0 0 1, R q1 , L q2
1 0, L q3
, R
A. Senthil - Professor/CSE
q4 20
CREATED BY K. VICTOR BABU
Time 1 1 1 0 1 1
q0
1 1, R 1 1, R 1 1, L
q0 0 1, R q1 , L q2
1 0, L q3
, R
A. Senthil - Professor/CSE
q4 21
CREATED BY K. VICTOR BABU
Time 2 1 1 0 1 1
q0
1 1, R 1 1, R 1 1, L
q0 0 1, R q1 , L q2
1 0, L q3
, R
A. Senthil - Professor/CSE
q4 22
CREATED BY K. VICTOR BABU
Time 3 1 1 1 1 1
q1
1 1, R 1 1, R 1 1, L
q0 0 1, R q1 , L q2
1 0, L q3
, R
A. Senthil - Professor/CSE
q4 23
CREATED BY K. VICTOR BABU
Time 4 1 1 1 1 1
q1
1 1, R 1 1, R 1 1, L
q0 0 1, R q1 , L q2
1 0, L q3
, R
A. Senthil - Professor/CSE
q4 24
CREATED BY K. VICTOR BABU
Time 5 1 1 1 1 1
q1
1 1, R 1 1, R 1 1, L
q0 0 1, R q1 , L q2
1 0, L q3
, R
A. Senthil - Professor/CSE
q4 25
CREATED BY K. VICTOR BABU
Time 6 1 1 1 1 1
q2
1 1, R 1 1, R 1 1, L
q0 0 1, R q1 , L q2
1 0, L q3
, R
A. Senthil - Professor/CSE
q4 26
CREATED BY K. VICTOR BABU
Time 7 1 1 1 1 0
q3
1 1, R 1 1, R 1 1, L
q0 0 1, R q1 , L q2
1 0, L q3
, R
A. Senthil - Professor/CSE
q4 27
CREATED BY K. VICTOR BABU
Time 8 1 1 1 1 0
q3
1 1, R 1 1, R 1 1, L
q0 0 1, R q1 , L q2
1 0, L q3
, R
A. Senthil - Professor/CSE
q4 28
CREATED BY K. VICTOR BABU
Time 9 1 1 1 1 0
q3
1 1, R 1 1, R 1 1, L
q0 0 1, R q1 , L q2
1 0, L q3
, R
A. Senthil - Professor/CSE
q4 29
CREATED BY K. VICTOR BABU
Time 10 1 1 1 1 0
q3
1 1, R 1 1, R 1 1, L
q0 0 1, R q1 , L q2
1 0, L q3
, R
A. Senthil - Professor/CSE
q4 30
CREATED BY K. VICTOR BABU
Time 11 1 1 1 1 0
q3
1 1, R 1 1, R 1 1, L
q0 0 1, R q1 , L q2
1 0, L q3
, R
A. Senthil - Professor/CSE
q4 31
CREATED BY K. VICTOR BABU
Time 12 1 1 1 1 0
q4
1 1, R 1 1, R 1 1, L
q0 0 1, R q1 , L q2
1 0, L q3
, R
HALT & accept
A. Senthil - Professor/CSE
q4 32
CREATED BY K. VICTOR BABU
Another Example
The function f ( x) 2 x is computable
x is integer
Turing Machine:
Start 1 1 1
q0 initial state
2x
Finish 1 1 1 1 1
q f final state
A. Senthil - Professor/CSE 34
CREATED BY K. VICTOR BABU
Turing Machine Pseudocode for f ( x) 2 x
• Repeat:
• Find rightmost $, replace it with 1
A. Senthil - Professor/CSE 35
CREATED BY K. VICTOR BABU
Turing Machine for f ( x) 2 x
1 $, R 1 1, L 1 1, R
q0 , L q1 $ 1, R q2
, R 1, L
q3
A. Senthil - Professor/CSE 36
CREATED BY K. VICTOR BABU
Example
Start Finish
1 1 1 1 1 1
q0 q3
1 $, R 1 1, L 1 1, R
q0 , L q1 $ 1, R q2
, R
1, L
q3 A. Senthil - Professor/CSE 37
CREATED BY K. VICTOR BABU
Another Example
1 if x y
The function f ( x, y )
0 if x y
is computable
A. Senthil - Professor/CSE 38
CREATED BY K. VICTOR BABU
Turing Machine for
1 if x y
f ( x, y )
0 if x y
Input: x0 y
Output: 1 or 0
A. Senthil - Professor/CSE 39
CREATED BY K. VICTOR BABU
Turing Machine Pseudocode:
• Repeat
A. Senthil - Professor/CSE 41
CREATED BY K. VICTOR BABU
Block Diagram
Turing
input output
Machine
A. Senthil - Professor/CSE 42
CREATED BY K. VICTOR BABU
Example: x y if x y
f ( x, y )
0 if x y
x, y
Adder x y
x, y x y
Comparer
x y Eraser 0
A. Senthil - Professor/CSE 43
CREATED BY K. VICTOR BABU
THANK YOU
Team – ATFL