SlideShare a Scribd company logo
UNIT-III
Topics
Push Down Automata: Push down automata, definition,
model, acceptance of CFL, by final state and by empty
stack.
Turing Machine: Turing Machine, definition, model, design
of TM, counter machine, types of Turing machines (proofs
not required).
Overview of Compilation: Phases of compilation-lexical
analysis, regular grammar and regular expression for
common programming language features, Pass and phases
of translation, interpretation, bootstrapping, data structures
in compilation
Push Down Automata
A pushdown automaton is a way to implement a context-free grammar in a
similar way we design DFA for a regular grammar. A DFA can remember a
finite amount of information, but a PDA can remember an infinite amount of
information.
Basically a pushdown automaton is −
"Finite state machine" + "a stack"
A pushdown automaton has three components −
an input tape,
a control unit, and
a stack with infinite size.
The stack head scans the top symbol of the stack.
A stack does two operations −
Push − a new symbol is added at the top.
Pop − the top symbol is read and removed.
Unit-3_TOC theory of computation subj.ppt
A PDA can be formally described as a 7-tuple (Q, ∑, S, δ, q0, I, F) −
Q is the finite number of states
∑ is input alphabet
S is stack symbols
δ is the transition function: Q × (∑ {ε}) × S × Q × S*
∪
q0 is the initial state (q0 Q)
∈
I is the initial stack top symbol (I S)
∈
F is a set of accepting states (F Q)
∈
The following diagram shows a transition in a PDA from a state q1 to state q2,
labeled as a,b → c
This means at state q1, if we encounter an
input string ‘a’ and top symbol of the stack
is ‘b’, then we pop ‘b’, push ‘c’ on top of
the stack and move to state q2.
Instantaneous Description (ID)
ID is an informal notation of how a PDA computes an input string and
make a decision that string is accepted or rejected.
An instantaneous description is a triple (q, w, α) where:
q describes the current state.
w describes the remaining input.
α describes the stack contents, top at the left.
Turnstile Notation:
⊢ sign describes the turnstile notation and represents one move.
⊢* sign describes a sequence of moves.
For example,
(p, b, T) (q, w, α)
⊢
In the above example, while taking a transition from state p to q, the
input symbol 'b' is consumed, and the top of the stack 'T' is
represented by a new string α.
Terminologies Related to PDA
Unit-3_TOC theory of computation subj.ppt
Unit-3_TOC theory of computation subj.ppt
Construct a PDA that accepts L = {an
bn
| n ≥ 0}
Unit-3_TOC theory of computation subj.ppt
Design A PDA for accepting a language {0n
1m
0n
| m, n>=1}.
Solution: In this PDA, n number of 0's are followed by any number of 1's followed
n number of 0's. Hence the logic for design of such PDA will be as follows:
Push all 0's onto the stack on encountering first 0's. Then if we read 1, just do
nothing. Then read 0, and on each read of 0, pop one 0 from the stack.
Now we will simulate this PDA for the input string "0011100".
1.δ(q0, 0011100, Z) δ(q0,
⊢ 011100, 0Z)
2. ⊢ δ(q0, 11100, 00Z)
3. ⊢ δ(q1, 1100, 00Z)
4. ⊢ δ(q1, 100, 00Z)
5. ⊢ δ(q1, 00, 00Z)
6. ⊢ δ(q1, 0, 0Z)
7. ⊢ δ(q1, ε, Z)
8. ⊢ δ(q2, Z)
9. ACCEPT
For instance:
This scenario can be written in the ID form as:
1.δ(q0, 0, Z) = δ(q0, 0Z)
2.δ(q0, 0, 0) = δ(q0, 00)
3.δ(q0, 1, 0) = δ(q1, 0)
4.δ(q1, 1, 0) = δ(q1, 0)
5.δ(q1, 0, 0) = δ(q1, ε)
6.δ(q1, ε, Z) = δ(q2, Z) (ACCEPT state)
The following symbols are used while drawing the PDA
Unit-3_TOC theory of computation subj.ppt
Unit-3_TOC theory of computation subj.ppt
Unit-3_TOC theory of computation subj.ppt
Turing Machine
• Turing machine was invented in 1936 by Alan Turing. It is an accepting device
which accepts Recursive Enumerable Language generated by type 0 grammar.
• There are various features of the Turing machine:
– It has an external memory which remembers arbitrary long sequence of
input.
– It has unlimited memory capability.
– The model has a facility by which the input at left or right on the tape can
be read easily.
– The machine can produce a certain output based on its input. Sometimes
it may be required that the same input has to be used to generate the
output. So in this machine, the distinction between input and output has
been removed. Thus a common set of alphabets can be used for the Turing
machine.
Formal definition of Turing machine
• A Turing machine can be defined as a collection of 7 components:
• Q: the finite set of states
∑: the finite set of input symbols
T: the tape symbol
q0: the initial state
F: a set of final states
B: a blank symbol used as a end marker for input
δ: a transition or mapping function.
• The mapping function shows the mapping from states of finite
automata and input symbol on the tape to the next states,
external symbols and the direction for moving the tape head. This
is known as a triple or a program for Turing machine.
(q0, a) → (q1, A, R)
• That means in q0 state, if we read symbol 'a' then it will go to state
q1, replaced a by A and move ahead right(R stands for right).
Basic Model of Turing machine
• The turning machine can be modeled with the help of the following
representation.
• 1. The input tape is having an infinite number of cells, each cell containing one
input symbol and thus the input string can be placed on tape. The empty tape is
filled by blank characters.
•
• 2. The finite control and the tape head which is responsible for reading the
current input symbol. The tape head can move to left to right.
• 3. A finite set of states through which machine has to undergo.
• 4. Finite set of symbols called external symbols which are used in building the
logic of Turing machine.
Language accepted by Turing machine
• The Turing machine accepts all the language even though they are recursively
enumerable.
• Recursive means repeating the same set of rules for any number of times and
enumerable means a list of elements.
• The TM also accepts the computable functions, such as addition, multiplication,
subtraction, division, power function, and many more.
Example:
• Construct a Turing machine which accepts the language of aba over ∑ = {a, b}.
Solution:
• We will assume that on input tape the string 'aba' is placed like this:
• The tape head will read out the sequence up to the Δ characters. If the tape
head is readout 'aba' string then TM will halt after reading Δ.
• Now, we will see how this Turing machine will work for aba. Initially, state is q0
and head points to a as:
• The move will be δ(q0, a) = δ(q1, A, R) which means it will go to state q1,
replaced a by A and head will move to right as:
The move will be δ(q1, b) = δ(q2, B, R) which means it will go to state q2,
replaced b by B and head will move to right as:
The move will be δ(q2, a) = δ(q3, A, R) which means it will go to state q3,
replaced a by A and head will move to right as:
• The move δ(q3, Δ) = (q4, Δ, S) which means it will go to state q4 which is
the HALT state and HALT state is always an accept state for any TM.
States a b Δ
q0 (q1, A, R) – –
q1 – (q2, B, R) –
q2 (q3, A, R) – –
q3 – – (q4, Δ, S)
q4 – – –
Transition Table Transition Diagram
Example:
Construct TM for the language L ={0n
1n
} where n>=1.
Solution:
• We have already solved this problem by PDA. In PDA, we have a stack to remember the
previous symbol. The main advantage of the Turing machine is we have a tape head which can
be moved forward or backward, and the input tape can be scanned.
• The simple logic which we will apply is read out each '0' mark it by A and then move ahead along
with the input tape and find out 1 convert it to B. Now, repeat this process for all a's and b's.
• Now we will see how this Turing machine work for 0011.
• The simulation for 0011 can be shown as below:
• Now, we will see how this Turing machine will works for 0011. Initially, state is q0 and head
points to 0 as:
The move will be δ(q0, 0) = δ(q1, A, R) which means it will go to state q1, replaced 0 by A and
head will move to the right as:
• The move will be δ(q1, 0) = δ(q1, 0, R) which means it will not change any symbol,
remain in the same state and move to the right as:
• The move will be δ(q1, 1) = δ(q2, B, L) which means it will go to state q2, replaced 1
by B and head will move to left as:
•
Now move will be δ(q2, 0) = δ(q2, 0, L) which means it will not change any symbol,
remain in the same state and move to left as:
•
The move will be δ(q2, A) = δ(q0, A, R), it means will go to state q0, replaced A by A
and head will move to the right as:
• The move will be δ(q0, 0) = δ(q1, A, R) which means it will go to state q1,
replaced 0 by A, and head will move to right as:
The move will be δ(q1, B) = δ(q1, B, R) which means it will not change any
symbol, remain in the same state and move to right as:
The move will be δ(q1, 1) = δ(q2, B, L) which means it will go to state q2,
replaced 1 by B and head will move to left as:
The move δ(q2, B) = (q2, B, L) which means it will not change any symbol,
remain in the same state and move to left as:
• Now immediately before B is A that means all the 0?s are market by A. So we
will move right to ensure that no 1 is present. The move will be δ(q2, A) = (q0, A,
R) which means it will go to state q0, will not change any symbol, and move to
right as:
The move δ(q0, B) = (q3, B, R) which means it will go to state q3, will not
change any symbol, and move to right as:
The move δ(q3, B) = (q3, B, R) which means it will not change any symbol,
remain in the same state and move to right as:
• The move δ(q3, Δ) = (q4, Δ, R) which means it will go to state q4 which is the
HALT state and HALT state is always an accept state for any TM.
• Example 1:
Construct a TM for the language L = {0n
1n
2n
} where n≥1
• Example 2:
Construct a TM machine for checking the palindrome of the string of
even length.
Types of TM
• Turing machines (TM) can also be deterministic or non-
deterministic, but this does not make them any more or less
powerful.
• However, if the tape is restricted so that you can only see use of
the part of the tape with the input, the TM becomes less powerful
(linear bounded automata) and can only recognize context
sensitive languages.
• Many other TM variations are equivalent to the original TM.
This includes the following −
– Multi-track
– Multi-tape
– Multi-head
– Multi-dimensional tape
– The off-line Turing machine
Multi-tape Turing Machine
• A Turing machine with several tapes we call it a multi tape Turing
machine.
• Every tape’s have their own Read/Write head
• For N-tape Turing Machine
• M={( Q,X, ∑,δ,q0,B,F)}
• We define
• δ=QxXN
->Q x XN
x {L,R}N
Example
• If n=2 with current configuration δ(q0,a,e)=(q1,X,Y,L,R)
Multi-track Turing machines
• A specific type of Multi-tape Turing machine, contain multiple tracks but just one
tape head reads and writes on all tracks. Here, a single tape head reads n
symbols from n tracks at one step. It accepts recursively enumerable languages
like a normal single-track single-tape Turing Machine accepts.
• A Multi-track Turing machine can be formally described as a 6-tuple (Q, X, ∑, δ,
q0, F) where −
• Q is a finite set of states
• X is the tape alphabet
• ∑ is the input alphabet
• δ is a relation on states and symbols where
• δ(Qi, [a1, a2, a3,....]) = (Qj, [b1, b2, b3,....], Left_shift or Right_shift)
• q0 is the initial state
• F is the set of final states
• Note − For every single-track Turing Machine S, there is an equivalent multi-
track Turing Machine M such that L(S) = L(M).
Non Deterministic Turing Machine
• It is similar to DTM except that for any input and current state it has
a number of choices.
• A string is accepted by a NDTM if there is a sequence of moves that
leads to a final state
• The Transition function − Q x X ->2QxXx(L,R)
• A NDTM is allowed to have more than one transition for a given
tape symbol.
Multi-head Turing machine
It has a number of heads instead of one.
Each head independently reads/ writes symbols and moves left/right or
keeps stationery.
Off-line Turing Machine
An offline Turing machine has two tapes, which are as follows −
One tape is read-only and contains the input.
The other is read-write and is initially blank.
Multi-dimensional Tape Turing Machine:
It has multi-dimensional tape where the head can move in any direction that
is left, right, up or down. Multi dimensional tape Turing machine can be
simulated by one-dimensional Turing machine
Counter Machine
• Counter machine has the same structure as the multi-stack
machine but in place of each stack is a counter.
• Counters hold any non-negative integer, but we can only
distinguish between zero and nonzero counters.
• That's the move of the counter machine depends on its
state, input symbol and which if any of the counters are
zero.
• In one move, the counter machine can
a)change state
b)Add or subtract 1 from any of its counters, independently. However
a counter is not allowed to become negative, so it cant subtract from
a counter that is currently 0.
35
COMPILER DESIGN
Content
36
Compiler:
Overview of Compiler-environment
phases of compiler
phase and pass
lexical analyzer
Bootstrapping
Data Structures in Compilation
Language Translator
• A Language translator is a program which accepts inputs as
a program written in source language (high- level language)
and produces an output, a program in another language i.e.,
target language
• Basic functions of language translator:
 Translating the high level language program into m/c
language program
 Detection and reporting of errors.
• Types of Language Translator:
 Compilers
 Interpreters
 Assemblers
Language Translators
• Compiler: Is a program takes a program written in a source language and
translates it into an equivalent program in a target language.
source program target program
error messages
• Interpreter: An interpreter is a program which translates a high level
language program into machine language and interprets each instruction
and executes it immediately.
• Assembler: An Assembler is a program which translates assembly
language to machine level language.
COMPILER
Compilers Interpreter
1.Compiler checks errors at
compile time
1.Interpreter checks for errors even
at runtime
2.A compiled program takes less
time for execution
2.Takes more time
3.Compilers requires more memory
while translation
3. Requires less memory space
4.Some compiled programming
languages are C , C++ etc
4. Interpreter languages are
LISP ,APL, Smalltalk, JavaScript,
PHP, Python, Perl, Ruby etc
Differences between compiler and interpreter
Library,relocatable
object files
Preprocessor
source program
Source program
Assembler
Target assembly program
Loader/linker
Relocatable machine code
Absolute machine code
#include
derectives
#define statements
#ifdef derectives
Where the compiler fits
Logical phases of compiler
The compiler implementation process is divided into two parts:
Analysis of a source program
Synthesis of a target program
Analysis involves analyzing the different constructs of the program
Analysis consists of three phases:
 Lexical (Linear) analysis or scanner
 Syntax Analysis or parser
 Semantic analysis
Synthesis of a target program includes three phases:
 Intermediate code generator
 code optimizer
 code generator
• Each phase transforms the source program from one
representation into another representation.
• They communicate with error handlers.
• They communicate with the symbol table.
Phases of compiler
Lexical analyzer
Syntax analyzer
Semantic analyzer
Intermediate code generator
Code Optimizer
Code generator
Error
Handler
Symbol
Table
Lexical
errors
syntax
semantic
tokens
Parse tree
Syntax tree
Intermediate code
Optimized code
Target program
Source program
Lexical Analyzer
Lexical Analyzer reads the source program character by
character to produce tokens.
Ex:
position= initial + rate* 60 ( C statement)
position, initial, rate : identifiers
= : assignment symbol
+, * : operators
60 : number (constant)
After lexical analysis phase the statement becomes :
id1 = id2 + id3 * 60
All the identifiers are stored in symbol table
Syntax Analyzer
• A Syntax Analyzer creates the syntactic structure (generally
a parse tree) of the given program.
• This phase receives the outcome of the lexical phase as input.
=
id1 +
id2 *
id3 60
It constructs parse tree for the statement
id1 = id2+id3 * 60
Semantic Analyzer
• A semantic analyzer checks the source program for semantic
errors and collects the type information for the code generation.
• Type-checking and type conversion are two important parts of
semantic analyzer.
=
id1 +
id2 *
id3
60. 0
Int to float
Intermediate Code Generation
• A compiler may produce an explicit intermediate
codes representing the source program.
• One such intermediate representation is :
Three address code
Ex: id1 = id2 + id3 * (int to float )60
temp1=inttofloat(60)
temp2=id3 *temp1
temp3=id2+temp2
id1=temp3
Code Optimizer
(for Intermediate Code Generator)
• The code optimizer optimizes the code produced by the
intermediate code generator in the terms of time and
space.
temp1:=id3*60.0
id1:=id2+temp1
temp1=inttofloat(60)
temp2=id3 *temp1
temp3=id2+temp2
id1=temp3
Code Generator
• Produces the target language in a specific architecture.
( assume that we have an architecture with instructions whose
at least one of its operands is a machine register)
MOVF id3, R2
MULF #60.0,R2
MOVF id2 ,R1
ADDF R2,R1
MOVF R1,id1
temp1:=id3*60.0
id1:=id2+temp1
Symbol Table Management :
When an identifier is recognized by the lexical analyzer , the
identifier is stored in symbol table.
The symbol table can also store the type and value of each
identifier.
Error Handler :
It is a system program of a compiler used for detecting and
reporting errors, encounter in each phase of a compiler.
Phases and Passes
Pass Phase
1.Pass is a physical scan over a
source program The portions of one
or more phases are combined into a
module called pass
1. A phase is a logically cohesive
operation that takes i/p in one form
and produces o/p in another form
2. Requires an intermediate file
between two passes
2. No need of any intermediate files
in between phases
3. Splitting into more no. of passes
reduces memory
4. Splitting into more no. of phases
reduces the complexity of the
program
4. Single pass compiler is faster than
two pass
4. Reduction in no. of phases,
increases the execution speed
Lexical Analyzer
The lexical analyzer is the first phase of compiler
• Basic functions of lexical analyzer:
1. It reads the characters and produces as output a sequence of tokens
2. It removes comments, white spaces (blank ,tab ,new line character)
from the source program.
3. If lexical analyzer identifies any token of type identifier ,they are
placed in symbol table
4. Lexical analyzer may keep track of the no. of new line characters
seen, so that a line number can be associated with an error
message.
• Terms used in lexical analysis
Lexeme: Lexemes are the smallest logical units of a program. It is
sequence of characters in the source program for which a token
is produced.
Tokens: Class of similar lexemes are identified by the same token.
Pattern : Pattern is a rule which describes a token
Ex: Pattern of an identifier is it consists of letters and digits
but the first character should be a letter.
int x = 10;
int is a lexeme for the token keyword
x is a lexeme for the token identifier
int
x
= Lexemes
10
The lexical analyzer must also pass additional information along with token,
when a pattern matches more than one lexeme. These items information are
called attributes for tokens.
Generally a token of type identifier has single attribute, i.e. pointer to the symbol
table entry.
Ex: x = y + 2
Lexeme < token , Token attribute >
x <identifier , pointer to the symbol table
entry>
= <assign-op , >
y <identifier , pointer to the symbol table>
+ <Add-op , >
2 <const , integer value 2>
Regular Expressions & Transition Diagrams
A notation which is used to specify the token is called Regular
Expression .
Regular expressions are constructed for any token over an alphabet.
Ex: A Pascal identifier is defined as “letter followed by zero or more
letters or digits”
The regular Expression that denotes an identifier by using above
pattern is
id=L(L+D)*
Where L={ a,b…z}
D ={ 0,1,..9}
The Lexical analyzer phase recognizes the tokens specified in
Regular Expression using “Transition Diagram”.
Application of Finite Automata to Lexical
Analyzer
In Lexical analyzer the finite automata is used to recognize the tokens.
Ex:
…….
………
int x, y , z;
z=x+y;
……..
i n t
Return{ keyword,
int }
L
L/D
;
,
=
+
Return { operator ,+}
Return {id }
Return {; }
Return {, }
Return {operator , = }
•As characters are read, the relevant TDs are used to attempt to
match lexeme to a pattern.
Ex: sum=a+b;
To recognize the tokens in above statement, three different
transition diagrams are used.
1) TD to recognize identifiers ( sum , a, b)
2) TD to recognize operators ( = , + )
3) TD to recognize special symbols ( ; )
A
; B
Above TD is used to recognize ; symbol
Bootstrapping
• Compiler is a complex program and should not be written
in assembly language
• How to write compiler for a language in the same
language (first time!)?
• First time this experiment was done for Lisp
• Initially, Lisp was used as a notation for writing functions.
• Functions were then hand translated into assembly
language and executed
• McCarthy wrote a function eval[e,a] in Lisp that took a
Lisp expression e as an argument
• The function was later hand translated and it became an
interpreter for Lisp 58
59
• The facility offered by a language to compile itself is the essence of
Bootstrapping.
• A compiler can be characterized by three languages: the source
language (S), the target language (T), and the implementation language
(I)
• The three language S, I, and T can be quite different. Such a compiler is
called cross-compiler
• This is represented by a T-diagram as:
• In textual form this can be represented as
SIT
S T
I
60
• Write a cross compiler for a language L in
implementation language S to generate code for
machine N
• Existing compiler for S runs on a different machine M
and generates code for M
• When Compiler LSN is run through SMM we get compiler
LMN
Data Structures in Compilation
Token
• Represented by an integer value or an enumeration
literal
• Sometimes, it is necessary to preserve the string of
characters that was scanned
• For example, name of an identifiers or value of a literal
Syntax Tree
• Constructed as a pointer-based structure
• Dynamically allocated as parsing proceeds
• Nodes have fields containing information collected by the
parser and semantic analyzer
Symbol Table
• Keeps information associate with all kinds of identifiers:
• Constants, variables, functions, parameters, types, fields,
etc.
• Identifiers are entered by the scanner, parser or semantic
analyzer
• Semantic analyzer adds type information and other
attributes
• Code generation and optimization phases use the
information in the symbol table
• Insertion, deletion and search operation needed to efficient
because they are frequent
• Hash table with constant time operations is usually the
preferred choice
• More than one symbol table may be used
Literal Table
• Stores constant values and string literal in a program
• One literal table applies globally to the entire program
• Used by the code generator to:
– Assign addresses for literals
– Enter data definitions in the target code file
• Avoids the replication of constants and strings
• Quick insertion and lookup are essential. Deletion is not
necessary
Temporary Files
• Used historically by old compilers due to memory
constraints
• Hold the data of various stages

More Related Content

Similar to Unit-3_TOC theory of computation subj.ppt (20)

PDF
Theory of computation and automata
Prof. Dr. K. Adisesha
 
PPTX
BCS503 TOC Module 5 PPT.pptx VTU academic Year 2024-25 ODD SEM
VENKATESHBHAT25
 
PPT
TuringMachineS FOUNDATION OF DATA SCIENCE
gokikayal1998
 
PPT
THEORY OF COMPUTATION PROCESS AND MECHANISUMS
gokikayal1998
 
PPTX
INTRODUTION Formal Language and Automatic Theory.pptx
SUNEEL37
 
PPT
TuringMachines and its introduction for computer science studetns
22f3002173
 
PPTX
push down automata
Christopher Chizoba
 
DOCX
TOA.docx
SidraMalik81
 
DOCX
TOA.docx
SidraMalik81
 
PPT
Lecture 1 CSE 322 LPU By 5th SEM .ppt Good
abcxyz19691969
 
PPT
CSE-322 lecture1 notes
databydevang
 
PPTX
03-FiniteAutomata.pptx
ssuser47f7f2
 
PPTX
TURING MACHINE.pptxTURING MACHINE.pptxTURING MACHINE.pptx
ArjunSinghRajput16
 
PDF
Turing machines
surekamurali
 
PPT
FiniteAutomata (1).ppt
ssuser47f7f2
 
PPT
FiniteAutomata.ppt
RohitPaul71
 
PDF
Formal Languages and Automata Theory Unit 1
Srimatre K
 
PPT
FiniteAutomata-DFA and NFA from Theory of Computation.ppt
AdharshKumarSingh
 
PPTX
symbolic_automata or Advanced Programming Practice.pptx
sudharsr
 
PDF
Preparatory_questions_final_exam_DigitalElectronics1 (1).pdf
rdjo
 
Theory of computation and automata
Prof. Dr. K. Adisesha
 
BCS503 TOC Module 5 PPT.pptx VTU academic Year 2024-25 ODD SEM
VENKATESHBHAT25
 
TuringMachineS FOUNDATION OF DATA SCIENCE
gokikayal1998
 
THEORY OF COMPUTATION PROCESS AND MECHANISUMS
gokikayal1998
 
INTRODUTION Formal Language and Automatic Theory.pptx
SUNEEL37
 
TuringMachines and its introduction for computer science studetns
22f3002173
 
push down automata
Christopher Chizoba
 
TOA.docx
SidraMalik81
 
TOA.docx
SidraMalik81
 
Lecture 1 CSE 322 LPU By 5th SEM .ppt Good
abcxyz19691969
 
CSE-322 lecture1 notes
databydevang
 
03-FiniteAutomata.pptx
ssuser47f7f2
 
TURING MACHINE.pptxTURING MACHINE.pptxTURING MACHINE.pptx
ArjunSinghRajput16
 
Turing machines
surekamurali
 
FiniteAutomata (1).ppt
ssuser47f7f2
 
FiniteAutomata.ppt
RohitPaul71
 
Formal Languages and Automata Theory Unit 1
Srimatre K
 
FiniteAutomata-DFA and NFA from Theory of Computation.ppt
AdharshKumarSingh
 
symbolic_automata or Advanced Programming Practice.pptx
sudharsr
 
Preparatory_questions_final_exam_DigitalElectronics1 (1).pdf
rdjo
 

Recently uploaded (20)

PPTX
811109685-CS3401-Algorithms-Unit-IV.pptx
archu26
 
PPTX
AI_Road_Safety_Project.pptx for class 10
prem001ni
 
PPTX
DEVELOPING-PARAGRAPHS.pptx-developing...
rania680036
 
PPTX
Chapter 1-1.pptx hwhahaiaiautsfzjakaiwueysuua
hibaaqabdirisaaq331
 
PPTX
sistem teknologi yang di desain untuk mahasiswa dan dosen agar memudahkan mer...
gamesonlya2rj
 
PDF
Ecowood.pdf | Tranquil Global Acoustics India
tranquil01
 
PDF
ARC-101-B-4.pdfxxxxxxxxxxxxxxxxxxxxxxxxx
IzzyBaniquedBusto
 
PPTX
Town planning is a concept used in architectural design. It plays a very impo...
IshikaPanchal11
 
PPTX
Urban design is a huge concept when it comes to planning.
IshikaPanchal11
 
PPTX
7psofmarketingandbranding-250114091831-cba08a7c (1).pptx
jamescarllfelomino6
 
PPTX
Elevating Elegance: Lobby Design Ideas by Germany’s Top Building Rendering Se...
Yantram Animation Studio Corporation
 
PDF
CS6801-MULTI-CORE-ARCHITECTURE-AND-PROGRAMMING_watermark.pdf
SriRanjani60
 
PPTX
办理学历认证UHI在读证明信英国赫特福德郡大学毕业证范本,UHI成绩单修改
Taqyea
 
DOCX
parts of transformer and application.docx
AbyotLetike
 
PDF
SS27 Men's Fashion Trend Book Peclers Paris
Peclers Paris
 
PPTX
Great_Discoverers_Nohzyxyxyzyzyzyzzyz_Imagptx
kevadiyahem07
 
PPTX
presentation prsentation presentation presentation
ssun76691
 
PPT
1744066yaar kya hai ye bolo not nice 4.ppt
preethikavarsha
 
PDF
EY-emeia-fso-assurance-viewpoint-technology (1).pdf
INKPPT
 
PDF
Uber Driver Hackday Sprint Solving Ride Cancellations
YellowSlice1
 
811109685-CS3401-Algorithms-Unit-IV.pptx
archu26
 
AI_Road_Safety_Project.pptx for class 10
prem001ni
 
DEVELOPING-PARAGRAPHS.pptx-developing...
rania680036
 
Chapter 1-1.pptx hwhahaiaiautsfzjakaiwueysuua
hibaaqabdirisaaq331
 
sistem teknologi yang di desain untuk mahasiswa dan dosen agar memudahkan mer...
gamesonlya2rj
 
Ecowood.pdf | Tranquil Global Acoustics India
tranquil01
 
ARC-101-B-4.pdfxxxxxxxxxxxxxxxxxxxxxxxxx
IzzyBaniquedBusto
 
Town planning is a concept used in architectural design. It plays a very impo...
IshikaPanchal11
 
Urban design is a huge concept when it comes to planning.
IshikaPanchal11
 
7psofmarketingandbranding-250114091831-cba08a7c (1).pptx
jamescarllfelomino6
 
Elevating Elegance: Lobby Design Ideas by Germany’s Top Building Rendering Se...
Yantram Animation Studio Corporation
 
CS6801-MULTI-CORE-ARCHITECTURE-AND-PROGRAMMING_watermark.pdf
SriRanjani60
 
办理学历认证UHI在读证明信英国赫特福德郡大学毕业证范本,UHI成绩单修改
Taqyea
 
parts of transformer and application.docx
AbyotLetike
 
SS27 Men's Fashion Trend Book Peclers Paris
Peclers Paris
 
Great_Discoverers_Nohzyxyxyzyzyzyzzyz_Imagptx
kevadiyahem07
 
presentation prsentation presentation presentation
ssun76691
 
1744066yaar kya hai ye bolo not nice 4.ppt
preethikavarsha
 
EY-emeia-fso-assurance-viewpoint-technology (1).pdf
INKPPT
 
Uber Driver Hackday Sprint Solving Ride Cancellations
YellowSlice1
 
Ad

Unit-3_TOC theory of computation subj.ppt

  • 2. Topics Push Down Automata: Push down automata, definition, model, acceptance of CFL, by final state and by empty stack. Turing Machine: Turing Machine, definition, model, design of TM, counter machine, types of Turing machines (proofs not required). Overview of Compilation: Phases of compilation-lexical analysis, regular grammar and regular expression for common programming language features, Pass and phases of translation, interpretation, bootstrapping, data structures in compilation
  • 3. Push Down Automata A pushdown automaton is a way to implement a context-free grammar in a similar way we design DFA for a regular grammar. A DFA can remember a finite amount of information, but a PDA can remember an infinite amount of information. Basically a pushdown automaton is − "Finite state machine" + "a stack" A pushdown automaton has three components − an input tape, a control unit, and a stack with infinite size. The stack head scans the top symbol of the stack. A stack does two operations − Push − a new symbol is added at the top. Pop − the top symbol is read and removed.
  • 5. A PDA can be formally described as a 7-tuple (Q, ∑, S, δ, q0, I, F) − Q is the finite number of states ∑ is input alphabet S is stack symbols δ is the transition function: Q × (∑ {ε}) × S × Q × S* ∪ q0 is the initial state (q0 Q) ∈ I is the initial stack top symbol (I S) ∈ F is a set of accepting states (F Q) ∈
  • 6. The following diagram shows a transition in a PDA from a state q1 to state q2, labeled as a,b → c This means at state q1, if we encounter an input string ‘a’ and top symbol of the stack is ‘b’, then we pop ‘b’, push ‘c’ on top of the stack and move to state q2.
  • 7. Instantaneous Description (ID) ID is an informal notation of how a PDA computes an input string and make a decision that string is accepted or rejected. An instantaneous description is a triple (q, w, α) where: q describes the current state. w describes the remaining input. α describes the stack contents, top at the left. Turnstile Notation: ⊢ sign describes the turnstile notation and represents one move. ⊢* sign describes a sequence of moves. For example, (p, b, T) (q, w, α) ⊢ In the above example, while taking a transition from state p to q, the input symbol 'b' is consumed, and the top of the stack 'T' is represented by a new string α. Terminologies Related to PDA
  • 10. Construct a PDA that accepts L = {an bn | n ≥ 0}
  • 12. Design A PDA for accepting a language {0n 1m 0n | m, n>=1}. Solution: In this PDA, n number of 0's are followed by any number of 1's followed n number of 0's. Hence the logic for design of such PDA will be as follows: Push all 0's onto the stack on encountering first 0's. Then if we read 1, just do nothing. Then read 0, and on each read of 0, pop one 0 from the stack.
  • 13. Now we will simulate this PDA for the input string "0011100". 1.δ(q0, 0011100, Z) δ(q0, ⊢ 011100, 0Z) 2. ⊢ δ(q0, 11100, 00Z) 3. ⊢ δ(q1, 1100, 00Z) 4. ⊢ δ(q1, 100, 00Z) 5. ⊢ δ(q1, 00, 00Z) 6. ⊢ δ(q1, 0, 0Z) 7. ⊢ δ(q1, ε, Z) 8. ⊢ δ(q2, Z) 9. ACCEPT For instance: This scenario can be written in the ID form as: 1.δ(q0, 0, Z) = δ(q0, 0Z) 2.δ(q0, 0, 0) = δ(q0, 00) 3.δ(q0, 1, 0) = δ(q1, 0) 4.δ(q1, 1, 0) = δ(q1, 0) 5.δ(q1, 0, 0) = δ(q1, ε) 6.δ(q1, ε, Z) = δ(q2, Z) (ACCEPT state)
  • 14. The following symbols are used while drawing the PDA
  • 18. Turing Machine • Turing machine was invented in 1936 by Alan Turing. It is an accepting device which accepts Recursive Enumerable Language generated by type 0 grammar. • There are various features of the Turing machine: – It has an external memory which remembers arbitrary long sequence of input. – It has unlimited memory capability. – The model has a facility by which the input at left or right on the tape can be read easily. – The machine can produce a certain output based on its input. Sometimes it may be required that the same input has to be used to generate the output. So in this machine, the distinction between input and output has been removed. Thus a common set of alphabets can be used for the Turing machine.
  • 19. Formal definition of Turing machine • A Turing machine can be defined as a collection of 7 components: • Q: the finite set of states ∑: the finite set of input symbols T: the tape symbol q0: the initial state F: a set of final states B: a blank symbol used as a end marker for input δ: a transition or mapping function. • The mapping function shows the mapping from states of finite automata and input symbol on the tape to the next states, external symbols and the direction for moving the tape head. This is known as a triple or a program for Turing machine. (q0, a) → (q1, A, R) • That means in q0 state, if we read symbol 'a' then it will go to state q1, replaced a by A and move ahead right(R stands for right).
  • 20. Basic Model of Turing machine • The turning machine can be modeled with the help of the following representation. • 1. The input tape is having an infinite number of cells, each cell containing one input symbol and thus the input string can be placed on tape. The empty tape is filled by blank characters. • • 2. The finite control and the tape head which is responsible for reading the current input symbol. The tape head can move to left to right. • 3. A finite set of states through which machine has to undergo. • 4. Finite set of symbols called external symbols which are used in building the logic of Turing machine.
  • 21. Language accepted by Turing machine • The Turing machine accepts all the language even though they are recursively enumerable. • Recursive means repeating the same set of rules for any number of times and enumerable means a list of elements. • The TM also accepts the computable functions, such as addition, multiplication, subtraction, division, power function, and many more. Example: • Construct a Turing machine which accepts the language of aba over ∑ = {a, b}. Solution: • We will assume that on input tape the string 'aba' is placed like this: • The tape head will read out the sequence up to the Δ characters. If the tape head is readout 'aba' string then TM will halt after reading Δ. • Now, we will see how this Turing machine will work for aba. Initially, state is q0 and head points to a as:
  • 22. • The move will be δ(q0, a) = δ(q1, A, R) which means it will go to state q1, replaced a by A and head will move to right as: The move will be δ(q1, b) = δ(q2, B, R) which means it will go to state q2, replaced b by B and head will move to right as: The move will be δ(q2, a) = δ(q3, A, R) which means it will go to state q3, replaced a by A and head will move to right as: • The move δ(q3, Δ) = (q4, Δ, S) which means it will go to state q4 which is the HALT state and HALT state is always an accept state for any TM.
  • 23. States a b Δ q0 (q1, A, R) – – q1 – (q2, B, R) – q2 (q3, A, R) – – q3 – – (q4, Δ, S) q4 – – – Transition Table Transition Diagram
  • 24. Example: Construct TM for the language L ={0n 1n } where n>=1. Solution: • We have already solved this problem by PDA. In PDA, we have a stack to remember the previous symbol. The main advantage of the Turing machine is we have a tape head which can be moved forward or backward, and the input tape can be scanned. • The simple logic which we will apply is read out each '0' mark it by A and then move ahead along with the input tape and find out 1 convert it to B. Now, repeat this process for all a's and b's. • Now we will see how this Turing machine work for 0011. • The simulation for 0011 can be shown as below: • Now, we will see how this Turing machine will works for 0011. Initially, state is q0 and head points to 0 as: The move will be δ(q0, 0) = δ(q1, A, R) which means it will go to state q1, replaced 0 by A and head will move to the right as:
  • 25. • The move will be δ(q1, 0) = δ(q1, 0, R) which means it will not change any symbol, remain in the same state and move to the right as: • The move will be δ(q1, 1) = δ(q2, B, L) which means it will go to state q2, replaced 1 by B and head will move to left as: • Now move will be δ(q2, 0) = δ(q2, 0, L) which means it will not change any symbol, remain in the same state and move to left as: • The move will be δ(q2, A) = δ(q0, A, R), it means will go to state q0, replaced A by A and head will move to the right as:
  • 26. • The move will be δ(q0, 0) = δ(q1, A, R) which means it will go to state q1, replaced 0 by A, and head will move to right as: The move will be δ(q1, B) = δ(q1, B, R) which means it will not change any symbol, remain in the same state and move to right as: The move will be δ(q1, 1) = δ(q2, B, L) which means it will go to state q2, replaced 1 by B and head will move to left as: The move δ(q2, B) = (q2, B, L) which means it will not change any symbol, remain in the same state and move to left as:
  • 27. • Now immediately before B is A that means all the 0?s are market by A. So we will move right to ensure that no 1 is present. The move will be δ(q2, A) = (q0, A, R) which means it will go to state q0, will not change any symbol, and move to right as: The move δ(q0, B) = (q3, B, R) which means it will go to state q3, will not change any symbol, and move to right as: The move δ(q3, B) = (q3, B, R) which means it will not change any symbol, remain in the same state and move to right as: • The move δ(q3, Δ) = (q4, Δ, R) which means it will go to state q4 which is the HALT state and HALT state is always an accept state for any TM.
  • 28. • Example 1: Construct a TM for the language L = {0n 1n 2n } where n≥1 • Example 2: Construct a TM machine for checking the palindrome of the string of even length.
  • 29. Types of TM • Turing machines (TM) can also be deterministic or non- deterministic, but this does not make them any more or less powerful. • However, if the tape is restricted so that you can only see use of the part of the tape with the input, the TM becomes less powerful (linear bounded automata) and can only recognize context sensitive languages. • Many other TM variations are equivalent to the original TM. This includes the following − – Multi-track – Multi-tape – Multi-head – Multi-dimensional tape – The off-line Turing machine
  • 30. Multi-tape Turing Machine • A Turing machine with several tapes we call it a multi tape Turing machine. • Every tape’s have their own Read/Write head • For N-tape Turing Machine • M={( Q,X, ∑,δ,q0,B,F)} • We define • δ=QxXN ->Q x XN x {L,R}N Example • If n=2 with current configuration δ(q0,a,e)=(q1,X,Y,L,R)
  • 31. Multi-track Turing machines • A specific type of Multi-tape Turing machine, contain multiple tracks but just one tape head reads and writes on all tracks. Here, a single tape head reads n symbols from n tracks at one step. It accepts recursively enumerable languages like a normal single-track single-tape Turing Machine accepts. • A Multi-track Turing machine can be formally described as a 6-tuple (Q, X, ∑, δ, q0, F) where − • Q is a finite set of states • X is the tape alphabet • ∑ is the input alphabet • δ is a relation on states and symbols where • δ(Qi, [a1, a2, a3,....]) = (Qj, [b1, b2, b3,....], Left_shift or Right_shift) • q0 is the initial state • F is the set of final states • Note − For every single-track Turing Machine S, there is an equivalent multi- track Turing Machine M such that L(S) = L(M).
  • 32. Non Deterministic Turing Machine • It is similar to DTM except that for any input and current state it has a number of choices. • A string is accepted by a NDTM if there is a sequence of moves that leads to a final state • The Transition function − Q x X ->2QxXx(L,R) • A NDTM is allowed to have more than one transition for a given tape symbol.
  • 33. Multi-head Turing machine It has a number of heads instead of one. Each head independently reads/ writes symbols and moves left/right or keeps stationery. Off-line Turing Machine An offline Turing machine has two tapes, which are as follows − One tape is read-only and contains the input. The other is read-write and is initially blank. Multi-dimensional Tape Turing Machine: It has multi-dimensional tape where the head can move in any direction that is left, right, up or down. Multi dimensional tape Turing machine can be simulated by one-dimensional Turing machine
  • 34. Counter Machine • Counter machine has the same structure as the multi-stack machine but in place of each stack is a counter. • Counters hold any non-negative integer, but we can only distinguish between zero and nonzero counters. • That's the move of the counter machine depends on its state, input symbol and which if any of the counters are zero. • In one move, the counter machine can a)change state b)Add or subtract 1 from any of its counters, independently. However a counter is not allowed to become negative, so it cant subtract from a counter that is currently 0.
  • 36. Content 36 Compiler: Overview of Compiler-environment phases of compiler phase and pass lexical analyzer Bootstrapping Data Structures in Compilation
  • 37. Language Translator • A Language translator is a program which accepts inputs as a program written in source language (high- level language) and produces an output, a program in another language i.e., target language • Basic functions of language translator:  Translating the high level language program into m/c language program  Detection and reporting of errors. • Types of Language Translator:  Compilers  Interpreters  Assemblers
  • 38. Language Translators • Compiler: Is a program takes a program written in a source language and translates it into an equivalent program in a target language. source program target program error messages • Interpreter: An interpreter is a program which translates a high level language program into machine language and interprets each instruction and executes it immediately. • Assembler: An Assembler is a program which translates assembly language to machine level language. COMPILER
  • 39. Compilers Interpreter 1.Compiler checks errors at compile time 1.Interpreter checks for errors even at runtime 2.A compiled program takes less time for execution 2.Takes more time 3.Compilers requires more memory while translation 3. Requires less memory space 4.Some compiled programming languages are C , C++ etc 4. Interpreter languages are LISP ,APL, Smalltalk, JavaScript, PHP, Python, Perl, Ruby etc Differences between compiler and interpreter
  • 40. Library,relocatable object files Preprocessor source program Source program Assembler Target assembly program Loader/linker Relocatable machine code Absolute machine code #include derectives #define statements #ifdef derectives Where the compiler fits
  • 41. Logical phases of compiler The compiler implementation process is divided into two parts: Analysis of a source program Synthesis of a target program Analysis involves analyzing the different constructs of the program Analysis consists of three phases:  Lexical (Linear) analysis or scanner  Syntax Analysis or parser  Semantic analysis Synthesis of a target program includes three phases:  Intermediate code generator  code optimizer  code generator
  • 42. • Each phase transforms the source program from one representation into another representation. • They communicate with error handlers. • They communicate with the symbol table.
  • 43. Phases of compiler Lexical analyzer Syntax analyzer Semantic analyzer Intermediate code generator Code Optimizer Code generator Error Handler Symbol Table Lexical errors syntax semantic tokens Parse tree Syntax tree Intermediate code Optimized code Target program Source program
  • 44. Lexical Analyzer Lexical Analyzer reads the source program character by character to produce tokens. Ex: position= initial + rate* 60 ( C statement) position, initial, rate : identifiers = : assignment symbol +, * : operators 60 : number (constant) After lexical analysis phase the statement becomes : id1 = id2 + id3 * 60 All the identifiers are stored in symbol table
  • 45. Syntax Analyzer • A Syntax Analyzer creates the syntactic structure (generally a parse tree) of the given program. • This phase receives the outcome of the lexical phase as input. = id1 + id2 * id3 60 It constructs parse tree for the statement id1 = id2+id3 * 60
  • 46. Semantic Analyzer • A semantic analyzer checks the source program for semantic errors and collects the type information for the code generation. • Type-checking and type conversion are two important parts of semantic analyzer. = id1 + id2 * id3 60. 0 Int to float
  • 47. Intermediate Code Generation • A compiler may produce an explicit intermediate codes representing the source program. • One such intermediate representation is : Three address code Ex: id1 = id2 + id3 * (int to float )60 temp1=inttofloat(60) temp2=id3 *temp1 temp3=id2+temp2 id1=temp3
  • 48. Code Optimizer (for Intermediate Code Generator) • The code optimizer optimizes the code produced by the intermediate code generator in the terms of time and space. temp1:=id3*60.0 id1:=id2+temp1 temp1=inttofloat(60) temp2=id3 *temp1 temp3=id2+temp2 id1=temp3
  • 49. Code Generator • Produces the target language in a specific architecture. ( assume that we have an architecture with instructions whose at least one of its operands is a machine register) MOVF id3, R2 MULF #60.0,R2 MOVF id2 ,R1 ADDF R2,R1 MOVF R1,id1 temp1:=id3*60.0 id1:=id2+temp1
  • 50. Symbol Table Management : When an identifier is recognized by the lexical analyzer , the identifier is stored in symbol table. The symbol table can also store the type and value of each identifier. Error Handler : It is a system program of a compiler used for detecting and reporting errors, encounter in each phase of a compiler.
  • 51. Phases and Passes Pass Phase 1.Pass is a physical scan over a source program The portions of one or more phases are combined into a module called pass 1. A phase is a logically cohesive operation that takes i/p in one form and produces o/p in another form 2. Requires an intermediate file between two passes 2. No need of any intermediate files in between phases 3. Splitting into more no. of passes reduces memory 4. Splitting into more no. of phases reduces the complexity of the program 4. Single pass compiler is faster than two pass 4. Reduction in no. of phases, increases the execution speed
  • 52. Lexical Analyzer The lexical analyzer is the first phase of compiler • Basic functions of lexical analyzer: 1. It reads the characters and produces as output a sequence of tokens 2. It removes comments, white spaces (blank ,tab ,new line character) from the source program. 3. If lexical analyzer identifies any token of type identifier ,they are placed in symbol table 4. Lexical analyzer may keep track of the no. of new line characters seen, so that a line number can be associated with an error message.
  • 53. • Terms used in lexical analysis Lexeme: Lexemes are the smallest logical units of a program. It is sequence of characters in the source program for which a token is produced. Tokens: Class of similar lexemes are identified by the same token. Pattern : Pattern is a rule which describes a token Ex: Pattern of an identifier is it consists of letters and digits but the first character should be a letter. int x = 10; int is a lexeme for the token keyword x is a lexeme for the token identifier int x = Lexemes 10
  • 54. The lexical analyzer must also pass additional information along with token, when a pattern matches more than one lexeme. These items information are called attributes for tokens. Generally a token of type identifier has single attribute, i.e. pointer to the symbol table entry. Ex: x = y + 2 Lexeme < token , Token attribute > x <identifier , pointer to the symbol table entry> = <assign-op , > y <identifier , pointer to the symbol table> + <Add-op , > 2 <const , integer value 2>
  • 55. Regular Expressions & Transition Diagrams A notation which is used to specify the token is called Regular Expression . Regular expressions are constructed for any token over an alphabet. Ex: A Pascal identifier is defined as “letter followed by zero or more letters or digits” The regular Expression that denotes an identifier by using above pattern is id=L(L+D)* Where L={ a,b…z} D ={ 0,1,..9} The Lexical analyzer phase recognizes the tokens specified in Regular Expression using “Transition Diagram”.
  • 56. Application of Finite Automata to Lexical Analyzer In Lexical analyzer the finite automata is used to recognize the tokens. Ex: ……. ……… int x, y , z; z=x+y; …….. i n t Return{ keyword, int } L L/D ; , = + Return { operator ,+} Return {id } Return {; } Return {, } Return {operator , = }
  • 57. •As characters are read, the relevant TDs are used to attempt to match lexeme to a pattern. Ex: sum=a+b; To recognize the tokens in above statement, three different transition diagrams are used. 1) TD to recognize identifiers ( sum , a, b) 2) TD to recognize operators ( = , + ) 3) TD to recognize special symbols ( ; ) A ; B Above TD is used to recognize ; symbol
  • 58. Bootstrapping • Compiler is a complex program and should not be written in assembly language • How to write compiler for a language in the same language (first time!)? • First time this experiment was done for Lisp • Initially, Lisp was used as a notation for writing functions. • Functions were then hand translated into assembly language and executed • McCarthy wrote a function eval[e,a] in Lisp that took a Lisp expression e as an argument • The function was later hand translated and it became an interpreter for Lisp 58
  • 59. 59 • The facility offered by a language to compile itself is the essence of Bootstrapping. • A compiler can be characterized by three languages: the source language (S), the target language (T), and the implementation language (I) • The three language S, I, and T can be quite different. Such a compiler is called cross-compiler • This is represented by a T-diagram as: • In textual form this can be represented as SIT S T I
  • 60. 60 • Write a cross compiler for a language L in implementation language S to generate code for machine N • Existing compiler for S runs on a different machine M and generates code for M • When Compiler LSN is run through SMM we get compiler LMN
  • 61. Data Structures in Compilation Token • Represented by an integer value or an enumeration literal • Sometimes, it is necessary to preserve the string of characters that was scanned • For example, name of an identifiers or value of a literal Syntax Tree • Constructed as a pointer-based structure • Dynamically allocated as parsing proceeds • Nodes have fields containing information collected by the parser and semantic analyzer
  • 62. Symbol Table • Keeps information associate with all kinds of identifiers: • Constants, variables, functions, parameters, types, fields, etc. • Identifiers are entered by the scanner, parser or semantic analyzer • Semantic analyzer adds type information and other attributes • Code generation and optimization phases use the information in the symbol table • Insertion, deletion and search operation needed to efficient because they are frequent • Hash table with constant time operations is usually the preferred choice • More than one symbol table may be used
  • 63. Literal Table • Stores constant values and string literal in a program • One literal table applies globally to the entire program • Used by the code generator to: – Assign addresses for literals – Enter data definitions in the target code file • Avoids the replication of constants and strings • Quick insertion and lookup are essential. Deletion is not necessary Temporary Files • Used historically by old compilers due to memory constraints • Hold the data of various stages