0% found this document useful (0 votes)
85 views

State Transition Diagrams & Turing Machines: Lect 3 CS1005: Logic and Computation

This document discusses state transition diagrams and Turing machines. It defines state transition diagrams as graphs that indicate the possible states of an automaton and the allowable transitions between states. Each transition is labeled with an input, output, and direction. The document also explains that a Turing machine has an infinite tape divided into cells, each containing a symbol from a finite alphabet. A Turing machine's program controls a head to read, write, and move left/right on the tape based on the symbol and state. Examples of Turing machines that recognize specific languages are provided.

Uploaded by

ItalianS
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
85 views

State Transition Diagrams & Turing Machines: Lect 3 CS1005: Logic and Computation

This document discusses state transition diagrams and Turing machines. It defines state transition diagrams as graphs that indicate the possible states of an automaton and the allowable transitions between states. Each transition is labeled with an input, output, and direction. The document also explains that a Turing machine has an infinite tape divided into cells, each containing a symbol from a finite alphabet. A Turing machine's program controls a head to read, write, and move left/right on the tape based on the symbol and state. Examples of Turing machines that recognize specific languages are provided.

Uploaded by

ItalianS
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 21

State Transition Diagrams & Turing

Machines
Lect 3
CS1005: Logic and Computation

Dr Nour Ali
Senior Lecturer in Computer Science
[email protected]
Table of Content
• Automata Theory
• State Transition Diagram
• Turing Machine
• Examples
• Summary
Automata Theory
• Automata theory deals with the logic of computation with respect to
simple machines, referred to as automata.
• Through automata, computer scientists are able to understand how
machines compute functions and solve problems.
• what it means for a function to be defined as computable or for a question to be
described as decidable.
• Automatons are abstract models of machines that perform computations
on an input by moving through a series of states or configurations. 
• At each state of the computation, a transition function determines the next
configuration on the basis of a finite portion of the present configuration.
Automated Machines
• Characteristics of such machines include:
• Inputs: assumed to be sequences of symbols selected from a finite set I of
input signals. Namely, set I is the set {x1, x,2, x3... xk} where k is the number of
inputs.
• Outputs: sequences of symbols selected from a finite set Z. Namely, set Z is
the set {y1, y2, y3 ... ym} where m is the number of outputs.
• States: finite set Q, whose definition depends on the type of automaton.
• Kinds of Automated Machines are:
• Turing Machines
• Finite State Machines
State Transition Diagram
• A diagram (graph) that indicates the possible states of automaton
and the allowable transitions between such states.
• Circles (Nodes) represent a state,
• Arrows represent state transitions.
• Each arrow also represents one instruction.
• An arrow is labeled with: current symbol (input), new symbol (output) and
direction.
Example of a State Diagram
• A, B, C and D are states.
1/1 • First state can sometimes have an arrow.
(There can be other representations)
0/1 • Arrows can represent transitions between
A B
two states
• Arrows can also just represent instructions
1/0 0/0 with no transition.
• Input
• Sometimes Output ( / )

1/1 1/1
0/1
D 0/0
C
State Transition Table
• The state transition table lists all possible combinations of the present
state and the inputs

Present state Input Next state Output


Example: State Transition Table
Present state Input Next state Output 1/1
A 1 A 1
0/1
A 0 B 1 A B

B 0 C 0 1/0 0/0
B 1 D 0
C 1 C 1
C 0 D 0 1/1 1/1
D 0 B 1 0/1
D 0/0
C
D 1 A 1
Turing Machine
• Has a model of computation that is sufficient to describe all
computers.
• There are different variations of describing a Turing Machine.

• A Turing Machine has a data structure called an infinite “Tape”.


Data structure (TAPE)
Σ ={0,1}
0 1 1 0 1 0 1 Δ Δ

• The tape is divided into cells. Each cell contains one symbol.
• Symbols on the tape are:
• from an Alphabet (Σ).
• The alphabet can be Σ ={0,1, a, b, x, $, etc}

•Δ denotes an empty or blank cell.


• Some books and sources use ⊔ to denote a blank cell.
• A head accesses one cell at a time:
• It can read
• It can write
• Can move left or right.
How does a Turing Machine work?
• At the beginning of computation, the head is at the beginning of the
tape

0 1 1 0 1 0 1 Δ Δ

• A state machine (Finite State Machine(next lecture)) or called a


Programme controls the head and its actions (read, write,
movement). Symbol to Direction to
Write Move “R”
Symbol to
or “L”
Read

0 / 1, R
A B
Turing Machine Transitions (Example)
0 1 1 0 1 0 1 Δ Δ

0 / 1, R
A B

• Result:

1 1 1 0 1 0 1 Δ Δ
The State Machine for Turing
• It is a Finite State Machine
• It has an initial state
• Final States where we stop computation:
• THE ACCEPT STATE
• THE REJECT STATE
• The machine may enter into a LOOP where we do not stop.
• It is a deterministic machine: Every state has one transition we can
take.
Formal Definition of a Turing Machine
Example 1
• A Turing Machine that recognizes language
• L=01*0
1/Y R

0/X, R 0/X, R
A B C What is the tape input alphabet?

Δ/Δ,R Σ ={0,1}

1/1, R
Δ/Δ,R
Δ/Δ,R 0/0, R
1/1,R Assume if an edge is missing it goes to
the Reject State
REJECT ACCEPT
Example 1

X0 Y1 1Y 0X Δ Δ

1/Y, R

0/X, R 0/X, R
A B C

Δ/Δ,R

1/1, R
Δ/Δ,R
Δ/Δ,R 0/0, R
1/1,R

REJECT ACCEPT
Example 2
• A Turing Machine that recognizes language
• L=0n 1n
• The Tape input: Σ ={0,1}

• A legal input is:

0 0 0 0 1 1 1 1 Δ
Example 2
X0 X0 0X 0X 1Y Y1 Y1 Y1 Δ

• ALGORITHM:
• STEP1: If 0 change to X
• Move right till we find 1
= {0,1, X, Y, Δ}
• ELSE REJECT
• STEP 2: Change 1 to X
• Move left till we find X
• REPEAT STEP 1 till there are 0’s
• MAKE SURE NO MORE 1’s
EXAMPLE 2: TURING MACHINE

0/0, R 0/0, L
Y/Y, R Y/Y, L

0/X, R 1/Y, L
A B C

Y/Y, R X/X,R

D Y/Y, R

Δ/Δ,L

Δ/Δ,L

ACCEPT
Summary
• A Turing Machine is a state machine but it has an infinite tape.
• The programme of a TM is represented as a diagram: depending on
the symbol under the head and the state, the machine writes a
symbol, moves left or right or stays in place, and/or changes state.
• Once a Turing Machine enters the accept state it stops.
Next Week
• Finite State Machines

You might also like