0% found this document useful (0 votes)
1 views28 pages

Chapter Two

Chapter two introduces finite automata and formal languages, explaining the fundamental concepts of automata theory, which models the core features of computers. It covers basic terminologies such as alphabets, strings, languages, and grammar, and distinguishes between deterministic (DFA) and non-deterministic finite automata (NFA). The chapter also details the formal definitions, classifications, and graphical representations of these automata, along with examples and conversion methods from NFA to DFA.

Uploaded by

anwar kadi
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)
1 views28 pages

Chapter Two

Chapter two introduces finite automata and formal languages, explaining the fundamental concepts of automata theory, which models the core features of computers. It covers basic terminologies such as alphabets, strings, languages, and grammar, and distinguishes between deterministic (DFA) and non-deterministic finite automata (NFA). The chapter also details the formal definitions, classifications, and graphical representations of these automata, along with examples and conversion methods from NFA to DFA.

Uploaded by

anwar kadi
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/ 28

Chapter two

Introduction to Finite
Automata and Formal
Language
Introduction

 Automata Theory models represent features at the core of all computers and
their applications.
 To model the hardware of a computer, we introduce the notion of an automaton
(plural, automata).
 An automaton is a construct that possesses all the indispensable features of a
digital computer.
 It accepts input, produces output, may have some temporary storage, and can
make decisions in transforming the input into the output.
 A formal language is an abstraction of the general characteristics of
programming languages.
 A formal language consists of a set of symbols and some rules of formation by
which these symbols can be combined into entities called sentences.
Theory of automata

 Theory of automata is a theoretical branch of computer science


and mathematical.
 It is the study of abstract machines and the computation
problems that can be solved using these machines.
 The abstract machine is called the automata.
 This automaton consists of states and transitions. The State is
represented by circles, and the Transition is represented by
arrows.
 Automata is the kind of machine that takes some string as input
and this input goes through a finite number of states and may
enter the final state.
Basic Terminologies in Automata
 TheTheory
basic terminologies used in Automata Theory:- Alphabets, Strings,
Languages, and Grammar.
 Symbols: Symbols are an entity or individual objects, which can be any letter,
alphabet or any picture. E.g.: 1, a, b, #
 Alphabets: A finite set of non-empty symbols. It is denoted by ∑ (sigma).
Examples: ∑ = {a, b} is the binary alphabet
∑ = {A, B, C, D} is the set of uppercase letters
String: a finite collection of symbols from the alphabet. The string is denoted by w.
Example1: If ∑ = {a, b}, various string that can be generated from ∑ are {ab, aa, aaa,
bb, bbb, ba, aba.....}.
o A string with zero occurrences of symbols is known as an empty string. It is
represented
by ε.
o The number of symbols in a string w is called the length of a string. It is denoted
by |w|.
Cont...
Example 2:
  w = 010; Number of String |w| = 3
  abcbz is a string over ? = {a, b, c, d… z}
  11001011 is a string over ? = {0, 1}
  )) ()(() is a string over ? = {(,)}
 Language: A language is a collection of appropriate string. A language which
is formed over Σ can be Finite or Infinite.
Example: 1
 L1 = {Set of string of length 2}, L1 = {aa, bb, ba, bb} Finite Language
 Example: 2
 L2 = {Set of all strings starts with 'a'}, L2= {a, aa, aaa, abb, abbb, ababb}
Infinite Language
Cont...

 Grammar
 A grammar defines a set of rules, and with the use of these
rules, valid sentences in a language are generated. Similar
to English language we have set of rules in automata,
which help us in creating sentences.
 A popular way to derive a grammar recursively is phrase-
structure grammar.
Finite Automata
 An automaton with a finite number of states is called a Finite automaton.
 Finite Automata can be classified into :
 Deterministic finite automata, non-deterministic finite automata, Regular
expression, context-free grammar, context-free language, Push down automata,
Turning machines, etc.
 Finite automata are used to recognize patterns.
 It takes the string of symbol as input and changes its state accordingly. When
the desired symbol is found, then the transition occurs.
 At the time of transition, the automata can either move to the next state or stay
in the same state.
 Finite automata have two states, Accept state or Reject state. When the
input string is processed successfully, and the automata reached its final state,
then it will accept.
Formal Definition of FA

 A finite automaton is a collection of 5-tuple (Q, ∑, δ,


q0, F), where:
 Q: finite set of states
 ∑: finite set of the input symbol
 q0: initial state
 F: final state
 δ: Transition function
Finite Automata Model:

 Finite automata can be represented by input tape and finite control.


 Input tape: It is a linear tape having some number of cells. Each input
symbol is placed in each cell.
 Finite control: The finite control decides the next state on receiving
particular input from input tape. The tape reader reads the cells one by
one from left to right, and at a time only one input symbol is read.
Types of Automata:

 There are two types of finite automata:


 DFA(deterministic finite automata)
 NFA(non-deterministic finite automata)
DFA vs NFA

 1. DFA
 DFA refers to deterministic finite automata. Deterministic refers to the uniqueness
of the computation. In the DFA, the machine goes to one state only for a particular
input character. DFA does not accept the null move.
 2. NFA
 NFA stands for non-deterministic finite automata. It is used to transmit any
number of states for a particular input. It can accept the null move.
 Some important points about DFA and NFA:
1. Every DFA is NFA, but NFA is not DFA.
2. There can be multiple final states in both NFA and DFA.
3. DFA is used in Lexical Analysis in Compiler.
4. NFA is more of a theoretical concept.
DFA (Deterministic finite automata)

• DFA refers to deterministic finite automata. Deterministic refers


to the uniqueness of the computation. The finite automata are
called deterministic finite automata if the machine is read an
input string one symbol at a time.
• In DFA, there is only one path for specific input from the current
state to the next state.
• DFA does not accept the null move, i.e., the DFA cannot change
state without any input character.
• DFA can contain multiple final states. It is used in Lexical Analysis
in Compiler.
 In the following diagram, we can see that from state q0 for input a, there
is only one path which is going to q1.
 Similarly, from q0, there is only one path for input b going to q2.
Formal Definition of DFA

 A DFA is a collection of 5-tuples same as we described


in the definition of FA.
1. Q: finite set of states
2. ∑: finite set of the input symbol
3. q0: initial state
4. F: final state
5. δ: Transition function
Graphical Representation of DFA

 Transition function can be defined as:δ: Q x ∑→Q


 A DFA can be represented by digraphs called state
diagram. In which:
1. The state is represented by vertices.
2. The arc labeled with an input character show the
transitions.
3. The initial state is marked with an arrow.
4. The final state is denoted by a double circle.
example

 Example 1:
 Q = {q0, q1, q2}
 ∑ = {0, 1}
 q0 = {q0}
 F = {q2}

Present State Next state for Input 0 Next State of Input 1


→q0 q0 q1
q1 q2 q1
*q2 q2 q2
 Example 1:
 Design a FA with ∑ = {0, 1} accepts those string which starts with 1 and
ends with 0.
 The FA will have a start state q0 from which only the edge with input 1
will go to the next state.
exercise

 Try This
 Design FA with ∑ = {0, 1} accepts even number of 0's and even number of
1's.
NFA (Non-Deterministic finite
automata)
• NFA stands for non-deterministic finite automata. It is easy to construct
an NFA than DFA for a given regular language.
• The finite automata are called NFA when there exist many paths for
specific input from the current state to the next state.
• Every NFA is not DFA, but each NFA can be translated into DFA.
• NFA is defined in the same way as DFA but with the following two
exceptions, it contains multiple next states, and it contains ε transition.
 In the following image, we can see that from state q0 for input a, there
are two next states q1 and q2, similarly, from q0 for input b, the next
states are q0 and q1.
 Thus it is not fixed or determined that with a particular input where to
go next. Hence this FA is called non-deterministic finite automata.
example
Formal definition of NFA:

 NFA also has five states same as DFA, but with different transition
function, as shown follows:δ: Q x ∑ →2Q
1. Q: finite set of states
2. ∑: finite set of the input symbol
3. q0: initial state
4. F: final state
5. δ: Transition function
Graphical Representation of an NFA

 An NFA can be represented by digraphs called state diagram. In which:


1. The state is represented by vertices.
2. The arc labeled with an input character show the transitions.
3. The initial state is marked with an arrow.
4. The final state is denoted by the double circle
Transition Table:

Present State Next state for Input 0 Next State of Input 1

→q0 q0, q1 q1

q1 q2 q0

*q2 q2 q1, q2
Conversion from NFA to DFA
 In this section, we will discuss the method of converting NFA to its
equivalent DFA.
 In NFA, when a specific input is given to the current state, the machine
goes to multiple states.
 It can have zero, one or more than one move on a given input symbol.
On the other hand, in DFA, when a specific input is given to the current
state, the machine goes to only one state.
 DFA has only one move on a given input symbol.
 Let, M = (Q, ∑, δ, q0, F) is an NFA which accepts the language L(M).
 There should be equivalent DFA denoted by M' = (Q', ∑', q0', δ', F')
such that L(M) = L(M').
Steps for converting NFA to DFA:

 Step 1: Initially Q' = ϕ


 Step 2: Add q0 of NFA to Q'. Then find the transitions from this
start state.
 Step 3: In Q', find the possible set of states for each input
symbol. If this set of states is not in Q', then add it to Q'.
 Step 4: In DFA, the final state will be all the states which contain
F(final states of NFA)
 Example 1:
 Convert the given NFA to DFA.
example

State 0 1

→q0 q0 q1

q1 {q1, q2} q1

*q2 q2 {q1, q2}


NFA to DFA

State 0 1
→[q0] [q0] [q1]
[q1] [q1, q2] [q1]
*[q2] [q2] [q1, q2]
*[q1, q2] [q1, q2] [q1, q2]
The End

 Any question????

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