0% found this document useful (0 votes)
23 views10 pages

FLAT Unit 1 LM

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

FLAT Unit 1 LM

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

FORMAL LANGUAGES AND AUTOMATA THEORY

IT

UNIT – I
FUNDAMENTALS

Objective: design DFA’s and NFA’s for the regular languages.

Syllabus: Strings, alphabet, language, operations, finite state machine, finite automaton model,
acceptance of strings and languages, deterministic finite automaton and non deterministic finite
automaton, transition diagrams and language recognizers.
Outcomes:
Bloom's
S. No Learning Outcomes Taxonomy
Level
1 Students will be able to define Symbol, Alphabet, String and Languages Remember
2 Students will be able to explain transition diagram, transition table with Understand
example
3 Students will be able to define Kleen closure. Remember
4 Students will be able to explain power of an alphabet Understand
5 Students will be able to write an automaton model Apply
6 Students will be able to define DFA and NFA Remember
7 Students will be able to differentiate the DFA and NFA Understand
8 Students will be able to construct NFAs and DFAs for given regular Apply
languages

Mathematical Notions:

o Set: It is a group of objects represented as a unit. Objects are called as elements.


eg:{1,2,3,4,5,.} or{ a, b, c, d,...}
 Є set membership (belongs to)

 ⊂ subset
 ∉ set non-membership(not belongs to)

 ⊆ subset or equal to
 A subset, A B, means that every element of A is also an element of B:
 If x Є A, then x Є B.
 empty set (ɸ)(epsilon)
o Set Operations : There are 4 basic set operations: union, intersection, complement, and
difference.
 Union:
• A B is the set that contains all the elements in either A or B or both:
A B = {x | x A or x B}.
• For example, if A = { 1, 2, 3} and B ={ 3, 4, 5}, then A B = { 1, 2, 3, 4, 5}
 Intersection:

A.Y:2019-20 GEC II-II


FORMAL LANGUAGES AND AUTOMATA THEORY
IT
• A B is the set that contains all the elements that are in both A and B:
A B = {x | x A and x B}.
• For example, if A = { 1, 2, 3} and B ={ 3, 4, 5}, then A B = { 3 }
 Complement:
• A' is the set that contains everything in the universal set that is not in
A:A' = {x | x U and x A}.
• For example, if U= { 2, 4, 6, 8, 10, 12} and A = { 2, 4}, then A' ={ 6,
8, 10, 12}
 Difference:
• A - B is the set that contains all the elements that are in A but not in B:
A - B = {x | x A and not x B}.
• For example, if A = { 1, 2, 3} and B ={ 3, 4, 5}, then A - B = { 1, 2 }

o Symbols: An abstract entity that has no meaning by itself, Letters from various alphabets,
digits and special characters are the most commonly used symbols.

o Alphabet: A finite set of symbols. An alphabet is often denoted by sigma(∑), yet can be
given any name.

A={a, b, c, d,...z} Says A is an alphabet that represent English letters.


B = {0, 1} Says B is an alphabet of two symbols, 0 and 1.
C = {a, b, c} Says C is an alphabet of three symbols, a, b and c.
D={0,1,2,3,4,5,6,7,8,9} Says D is an alphabet represent digits

 Powers of an alphabet: If Σ is an alphabet, then Σ0 = ε, no matter what the alphabet Σ is. In


other words ε is the only string of length 0.
 If Σ = {a, b, c} then Σ1 = {a, b, c}, Σ2 = {aa, ab, ac, ba, bb, bc, ca, cb, cc}, Σ3 = {aaa, aab,
aac, aba, abb, abc, aca, acb, acc, baa, bab, bac, bba,bbb, bbc, bca, bcb, bcc, caa, cab, cac,
cba, cbb, cbc, cca, ccb, ccc}The set of all strings over an alphabet Σ is conventionally
denoted by Σ*. For instance {0, 1}* = {ε, 0, 1, 00, 01, 10, 11, 000,… }. Another way is
Σ* = Σ0 ᴜ Σ1 ᴜ Σ2 ᴜ …The set of nonempty strings of an alphabet Σ is denoted as Σ+.
And the two appropriate equivalences are :Σ+ = Σ1ᴜΣ2ᴜΣ3ᴜ … Σ* = Σ+ ᴜ {ε}

o A String over an alphabet Σ is a finite sequence of symbols of Σ.


o String over an alphabet is a finite sequence of symbols from the alphabet, usually written
next to one another and not separated by commas.
 If Σ1 = {0, 1} then 01001 is a string over the alphabet Σ1.
 If Σ2 = {a, b, c,…, z} then abracadabra is a string over Σ2.
 If w is a string over Σ then the length of w is written as |w| which is the number of
symbols that it contains.
 The string of length zero is called the empty string. It is written as ε(Epsilon).

A.Y:2019-20 GEC II-II


FORMAL LANGUAGES AND AUTOMATA THEORY
IT
 The empty string plays the role of 0 in a number system. If w has length n then we
can write w =w1, w2, …, ws where each wi Є Σ.
 The reverse of w written as wR is the string obtained by writing b in the opposite
order (i.e. wn, wn-1, … , w1).

Operations on strings:
 Concatenation of strings
The concatenation of two strings is the string formed by writing the first, followed
by the second, with no intervening space. Concatenation of strings is denoted by ◦.
That is, if w and x are strings, then wx is the concatenation of these two strings.
Example:
The concatenation of dog and house is doghouse.
Let x=0100101 and y= 1111 then x ◦ y=01001011111

 String Reversal
Reversing a string means writing the string backwards.
It is denoted by wR
Example:
Reverse of the string abcd is dcba.

If w= wR , then that string is called palindrome.

 Substring
A substring is a part of a string.
Example:
If abcd is string then possible substrings are ε,a,b,c,d,ab,bc,cd,abc,bcd are proper
substrings for the given string
A prefix of a string is any number of leading symbols of that string.
A suffix of a string is any number of trailing symbols.
Example:
String abc has prefixes ε, a, ab, and abc; its suffixes are ε, c, bc, and abc.
A prefix or suffix of a string, other than the string itself, is called a proper prefix or
suffix.
 A language is a set of strings.
o A set of strings all of which are chosen from Σ*, where Σ is a particular alphabet, is called
language.
o Examples:
 The language of all strings consisting of n 0’s followed by n 1’s for some n≥0; { ε,
01, 0011, 000111, . . . }.
 The set of strings of 0’s and 1’s with an equal number of each : {ε, 01, 10, 0011,
0101, 1001, . . .}
 The set of binary values whose value is prime: {10, 11, 101, 111, 1011,. . .}
 Σ* is a language for any alphabet Σ.
 ɸ the empty language is a language over any alphabet.
 {ε} the language consisting of only the empty string, is also a language over

A.Y:2019-20 GEC II-II


FORMAL LANGUAGES AND AUTOMATA THEORY
IT
any alphabet.

Operations on languages:
 Union
If L1 and L2 are two languages over an alphabet ∑.Then the union of L1 and L2
is denoted by L1 U L2.
Example:
L1={0,01,011} and L2={001},then L1 U L2={0,01,011,001}
 Intersection
If L1 and L2 are two languages over an alphabet ∑.Then the intersection of L1
and L2 is denoted by L1 ∩ L2.
Example:
L1= {0, 01,011} and L2= {01}, then L1 ∩ L2= {01}
 Complementation
L is a language over an alphabet ∑, then the complement of L denoted by L¯ ,is
the language consisting of those strings that are not in L over the alphabet.
Example:
If ∑={a,b} and L={a,b,aa} then L¯= ∑* - L={ ε,a,b,aa,bb,ab.........}-
{a,b,aa}={ε,bb,ab,ba.........}

 Concatenation
Concatenation of two languages L1 and L2 is the language L1 o L2 ,each element
of which is a string formed by combining one string of L1 with another string of
L2.
Example:

L1={bc,bcc,cc}andL2={cc,ccc},thenL1oL2={bccc,bcccc,bcccccc,cccc,ccccc}

 Reversal
If L is language, then LR is obtained by reversing the corresponding string in L. This
operation is similar to the reversal of a string.

∈ L}
LR ={wR | w

Example:
If L= {0, 011, 0111}, then LR = {0, 110, 1110}

 Kleene Closure
The Kleene closure (or just closure) of L, denoted L*, is the set and the positive closure

A.Y:2019-20 GEC II-II


FORMAL LANGUAGES AND AUTOMATA THEORY
IT
of L, denoted L+ , is the set


L * = U Li
i=0


L = U Li
+

i=1

That is, L* denotes words constructed by concatenating any number of words from L.
L+ is the same, but the case of zero words, whose "concatenation" is defined to be ε, is
excluded. Note that L+ contains ε if and only if L does.
Example:
Let L1 = {10, 1}
Then L * = L0 U L1 U L2.................. = {ε, 1, 10, 11, 111, 1111 ,..........}
L + = L1 U L2 U L3...................= {1, 10, 11, 111, 1111...........}

FINITE STATE MACHINE


 A finite-state machine (FSM) or simply a state machine is a mathematical model of
computation used to design both computer programs and sequential logic circuits.
 It is conceived as an abstract machine that can be in one of a finite number of states. The
machine is in only one state at a time; the state it is in at any given time is called the current
state.
 It can change from one state to another when initiated by a triggering event or condition, this is
called a transition. A particular FSM is defined by a list of its states, and the triggering
condition for each transition.
 Finite State machine is also termed as finite automaton.
 Finite automata are good models for computers with an extremely limited amount of
memory.
 A computer can do a lot of useful things with such a small memory.
 The controller for an automatic door is one example of such a device which is often
found at supermarket entrances and exits.
 Also automatic doors swing open when sensing that a person is approaching. It has a
pad in front to detect the presence of a person about to walk through the doorway.
 This controller is a computer that has just a single bit of memory, capable of recording
which of the two states the controller is in.
 Other common devices have controllers with somewhat larger memories. In an elevator
controller a state may represent the floor the elevator is on and the inputs might be the

A.Y:2019-20 GEC II-II


FORMAL LANGUAGES AND AUTOMATA THEORY
IT
signals received the buttons.
 This computer might need several bits to keep track of the information. Controllers for
various household appliances like dishwashers, electronic thermostats, as well as parts of
digital watches and calculators are additional examples of computers with limited
memories.
 The design of this kind of devices requires keeping the methodology and terminology of
finite automata in mind.
 Finite automata and their probabilistic counterpart Markov Chains are useful tools when
we are attempting to recognize patterns in data. These devices are used in speech
processing and in optical character recognition.

Finite Automaton Model:

Block diagram of a finite automaton


The various components are explained as follows:
(i) Input tape:
 The input tape is divided into squares, each square containing a single symbol from the
input alphabet ∑.
 The end squares of the tape contain the endmarker ¢ at the left end and the endmarker $
at the right end.
 The absence of endmarkers indicates that the tape is of infinite length. The left-to-right
sequence of symbols between the two endmarkers is the input string to be processed.
(ii) Reading head:
 The head examines only one square at a time and can move one square either to the left
or to the right.
 For further analysis, we restrict the movement of the R-head only to the right side.
(iii) Finite control: The input to the finite control will usually be the symbol under the R-head,
say a, and the present state of the machine, say q, to give the following outputs:
(a) A motion of R-head along the tape to the next square (in some a null move, i.e. the R-head
remaining to the same square is permitted)
(b) The next state of the finite state machine given by δ(q, a).
ACCEPTANCE OF STRINGS AND LANGUAGES:
ACCEPTABILITY OF STRING BY FINITE AUTOMATON

A.Y:2019-20 GEC II-II


FORMAL LANGUAGES AND AUTOMATA THEORY
IT
 Def: A string x is accepted by a finite automaton M = (Q, Σ, δ, q0, F) if δ(q0, x) =q for
some q Є F. This is basically the acceptability of a string by the final state.
 Note: A final state is also called an accepting state.
 If A is the set of all strings that machine M accepts then we say that A is the language of
machine M and written as L(M) = A. we say that M recognizes A or M accepts A.
Types of Finite Automata

Finite Automata

Finite Automata with output Finite Automata without output

Non-Deterministic Deterministic Finite


Mealy machine Moore machine Finite Automata (NFA) Automata (DFA)

ε -NFA NFA

Deterministic Finite Automaton (DFA):

In DFA, for each input symbol, one can determine the state to which the machine will move.
Hence, it is called Deterministic Automaton. As it has a finite number of states, the machine is
called Deterministic Finite Machine or Deterministic Finite Automaton.

Formal Definition of a DFA

A DFA can be represented by a 5-tuple (Q, ∑, δ, q0, F) where −

 Q is a finite set of states.


 ∑ is a finite set of symbols called the alphabet.

q0 is the initial state from where any input is processed (q0 ∈ Q).
 δ is the transition function where δ: Q × ∑ → Q

F is a set of final state/states of Q (F ⊆ Q).



Non-Deterministic Finite Automaton (NFA or NDFA):

In NDFA, for a particular input symbol, the machine can move to any combination of the states
in the machine. In other words, the exact state to which the machine moves cannot be

A.Y:2019-20 GEC II-II


FORMAL LANGUAGES AND AUTOMATA THEORY
IT
determined. Hence, it is called Non-deterministic Automaton. As it has finite number of states,
the machine is called Non-deterministic Finite Machine or Non-deterministic Finite
Automaton.

Formal Definition of an NDFA

An NDFA can be represented by a 5-tuple (Q, ∑, δ, q0, F) where −

 Q is a finite set of states.

δ is the transition function where δ: Q × {∑ ∪ ε} → 2Q (Here the power set of Q (2Q) has
 ∑ is a finite set of symbols called the alphabets.

been taken because in case of NDFA, from a state, transition can occur to any

q0 is the initial state from where any input is processed (q0 ∈ Q).
combination of Q states)

F is a set of final state/states of Q (F ⊆ Q).



1. Design DFA that accepts all strings which starts with ‘a’ over the alphabet {a,b}

Transition table
Input
State
a b
q0 q2 q1
q1 q1 q1
q1
q2 q2 q2

2. Design DFA that accepts all strings which contains ‘00’ as substring over the alphabet
{0,1}

A.Y:2019-20 GEC II-II


FORMAL LANGUAGES AND AUTOMATA THEORY
IT

Tuple Representation:
M(Q, ∑, δ, q0, F) where

Q= finite set of states={ q0,q1,q2}


∑=finite set of inputs={0,1}
δ=transition function maps
q0 =initial state=q0
F=set of final states={q2}
Language recognizers:
A language recognizer is a device that accepts valid strings produced in a given language.
Finite state automata are formalized types of language recognizers.
The language accepted by Finite Automata M designated L(M) is the set {x | δ(q0,x) is in F}.
Applications of FA:
 Used in Lexical analysis phase of a compiler to recognize tokens.
 Used in text editors for string matching.

Differences between NFA and DFA:

S. No NFA DFA
A nondeterministic finite automaton is A deterministic finite automaton can be
a 5-tuple represented by a 5-tuple
1 M= (Q, ∑, δ, qo, F), where M= (Q, ∑, δ, qo, F), where
δ: Q x ∑ into 2Q. δ: Q x ∑ to Q.

NFA is the one in which there DFA is a FA in which there is only


exists many paths for a specific one path for a specific input from
2
input from current state to next current state to next state.
state.
3 NFA is easier to construct. DFA is more difficult to construct.
4 NFA requires less space. DFA requires more space.
Time required for executing an Time required for executing an input
5
input string is more. string is less.
Transitions could be non All transitions are deterministic
deterministic
A transition could lead to subset Each transition leads to exactly one
of states. state

A.Y:2019-20 GEC II-II


FORMAL LANGUAGES AND AUTOMATA THEORY
IT

For each state not all symbols For each state, transition on all
necessarily have to defined in the possible symbols should be defined
transition functions
Accepts input if one of the last Accepts input if the last state is in F
states is in F
Generally easier than a DFA to Sometimes harder to construct
construct because of the number of states.

A.Y:2019-20 GEC II-II

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