0% found this document useful (0 votes)
9 views44 pages

Session 33-34-38

Uploaded by

Srinivas Bathula
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views44 pages

Session 33-34-38

Uploaded by

Srinivas Bathula
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 44

Department of CSE(H)

AUTOMATA THEORY AND FORMAL


LANGUAGES
22CS2215A
Topic:

RECURSIVELY ENUMERABLE
AND RECURSIVE LANGUAGE
Session – 33-34-38

CREATED BY K. VICTOR BABU


AIM OF THE SESSION
The aim of this session is to provide an understanding of recursively enumerable and recursive languages, the computation of
functions using Turing Machines, and the concept of combining multiple Turing Machines.

INSTRUCTIONAL OBJECTIVES

This Session is designed to:


•To define and differentiate recursively enumerable and recursive languages.
•To explain how Turing Machines can be used to compute functions and solve computational problems.
•To demonstrate the process of combining multiple Turing Machines to perform complex computations.

LEARNING OUTCOMES

At the end of this session, you should be able to:


1. Differentiate between recursively enumerable and recursive languages.
2. Analyze the computational complexity of functions and evaluate their computability using Turing Machines.
3. Design and implement a combined Turing Machine to solve a given computational problem.

CREATED BY K. VICTOR BABU


Recursively Enumerable
and
Recursive Languages

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

if w L then M halts in a non-final state


or loops forever
5
CREATED BY K. VICTOR BABU
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
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:

if w L then M halts in a final state

if w L then M halts in a non-final state


A. Senthil - 7
CREATED BY K. VICTOR BABU
Computing Functions
with
Turing Machines

A. Senthil - Professor/CSE 8
CREATED BY K. VICTOR BABU
A function f (w) has:

Domain: D Result Region: S

f (w)
w D f ( w)  S

A. Senthil - Professor/CSE 9
CREATED BY K. VICTOR BABU
A function may have many parameters:

Example: Addition function

f ( x, y )  x  y

A. Senthil - Professor/CSE 10
CREATED BY K. VICTOR BABU
Integer Domain

Decimal: 5

Binary: 101

Unary: 11111

We prefer unary representation:

easier to manipulate with Turing machines


A. Senthil - Professor/CSE 11
CREATED BY K. VICTOR BABU
Definition:

A function f is computable if
there is a Turing Machine M such that:

Initial configuration Final configuration


 w   f (w) 

q0 initial state q f final state

For all w D Domain


A. Senthil - Professor/CSE 12
CREATED BY K. VICTOR BABU
In other words:
A function f is computable if
there is a Turing Machine M such that:


q0 w  q f f ( w)

Initial Final
Configuration Configuration

For all w D Domain


A. Senthil - Professor/CSE 13
CREATED BY K. VICTOR BABU
Example
The function f ( x, y )  x  y is computable

x, y are integers

Turing Machine:

Input string: x0 y unary

Output string: xy 0 unary


A. Senthil - Professor/CSE 14
CREATED BY K. VICTOR BABU
x y

Start  1 1  1 0 1  1 

q0
initial state

The 0 is the delimiter that


separates the two numbers

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:

Input string: x unary

Output string: xx unary


A. Senthil - Professor/CSE 33
CREATED BY K. VICTOR BABU
x

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

• Replace every 1 with $

• Repeat:
• Find rightmost $, replace it with 1

• Go to right end, insert 1

Until no more $ remain

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

Match a 1 from x with a 1 from y

Until all of x or y is matched

• If a 1 from x is not matched


erase tape, write 1 ( x  y)
else

CREATED BY K. VICTOR BABU


eraseA. tape, write 0
Senthil - Professor/CSE ( x  y) 40
Combining Turing Machines

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

CREATED BY K. VICTOR BABU

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy