Post on 08-Apr-2018
8/7/2019 Chapter 1 Intro to Formal Lang and Automata
1/31
Formal Languages and Automata
Theory
8/7/2019 Chapter 1 Intro to Formal Lang and Automata
2/31
What do we do here? We construct abstract models of
computers and computations
These models possess the importantfeatures that are common to bothhardware and software
These features are essential to many ofthe special and complex constructs weencounter while working with computers
8/7/2019 Chapter 1 Intro to Formal Lang and Automata
3/31
Models The construction of models is one of the
essentials of any scientific discipline.
The usefulness of a discipline is often
dependent on the existence of simple,
yet powerful, theories and laws.
8/7/2019 Chapter 1 Intro to Formal Lang and Automata
4/31
Automata To model the hardware of the computer, a
construct called automaton is used.
An automaton is a construct that
possesses all the indispensable features
of a digital computer
Many automaton form an automata
8/7/2019 Chapter 1 Intro to Formal Lang and Automata
5/31
Automaton It accepts input, produces output, may
have some temporary storage and can
make decisions in transforming the input
into the output
8/7/2019 Chapter 1 Intro to Formal Lang and Automata
6/31
Formal Language It is an abstraction of the general
characteristics of programminglanguages
It consists of a set of symbols and somerules of formation of sentences
Sentences are formed by grouping thesymbols
8/7/2019 Chapter 1 Intro to Formal Lang and Automata
7/31
Formal Language A formal language is the set of all
strings permitted by the rules offormation
Study of formal languages is very usefulin learning about the different
programming languages
8/7/2019 Chapter 1 Intro to Formal Lang and Automata
8/31
What is a language? A system for the expression of certain ideas,
facts, or concepts, including a set of
symbols and rules for their manipulation
8/7/2019 Chapter 1 Intro to Formal Lang and Automata
9/31
Mathematical definition of a
language This shall require us to understand the
following concepts first
Alphabets
Strings
Concatenation of strings etc.
8/7/2019 Chapter 1 Intro to Formal Lang and Automata
10/31
Alphabet An ALPHABET is a nonempty set of
symbols
It is denoted by 7
Example:
7!{a,b}where a and b are symbols
8/7/2019 Chapter 1 Intro to Formal Lang and Automata
11/31
Strings Strings are constructed from the
individual symbols
Strings are finite sequences of symbolsfrom the alphabet
Example : aabba, ababaaa, abbbaaa,etc are the strings formed by t hesymbols of the alphabet
8/7/2019 Chapter 1 Intro to Formal Lang and Automata
12/31
Assumptions Lower case letters a,b,c, are used for
elements of the alphabet
Lower case letters u,v,w, for stringnames eg w=aabbaba
This indicates that w is a string havingspecific value aabbaba
8/7/2019 Chapter 1 Intro to Formal Lang and Automata
13/31
Concatenation of the strings Two strings are concatenated by
appending the symbols of one string tothe end of the other string
Example u=aaabbb
v=abbabba
Concatenated string uv=aaabbbabbabba
8/7/2019 Chapter 1 Intro to Formal Lang and Automata
14/31
Reverse of the string The reverse of a string is obtained by
writing the symbols in reverse order.
Example
w
R
= anan-1an-2a0Where w= a0a1a2an
8/7/2019 Chapter 1 Intro to Formal Lang and Automata
15/31
Length of the string The length of the string is the number
of symbols in the string
|w| = 5 if w = aabaa
Empty String has no symbols and isdenoted by P
`P` = 0
8/7/2019 Chapter 1 Intro to Formal Lang and Automata
16/31
7
and 7
7 is an alphabet
7
is the set of all strings obtained byconcatenating zero or more symbolsfrom 7
7always contains Pthen
7 !7 _Pa
8/7/2019 Chapter 1 Intro to Formal Lang and Automata
17/31
Finiteness 7is always finite
7
and 7
are always infinite
8/7/2019 Chapter 1 Intro to Formal Lang and Automata
18/31
Language A language L is defined very generally
as a subset of7
Astring in a language L will be called asentence of L
8/7/2019 Chapter 1 Intro to Formal Lang and Automata
19/31
Problem 7!_a,ba
7
!_Pa,b,aa,ab,ba,bb,aaa,aab,aba,abb, baa,bab,bba,bbb,aaaa, .}
L = {a,aa,aab} is a language on 7as Lis a subset of7 and is finite
L = {anbn:n>0} is also a subset of7
but it is infinite
8/7/2019 Chapter 1 Intro to Formal Lang and Automata
20/31
Concatenation of two
Languages L1L2 = {xy :x L1 and y L2 }
8/7/2019 Chapter 1 Intro to Formal Lang and Automata
21/31
Automaton An automaton is an abstract model of a
digital computer
It has a mechanism to read input(string over a given alphabet, e.g.strings of 0s and 1s on 7 = {0,1})
The automaton can produce output ofsome form
8/7/2019 Chapter 1 Intro to Formal Lang and Automata
22/31
Automaton It has a mechanism for reading input
where input is a string over a givenalphabet written on an input file, whichan automaton can read but not change
8/7/2019 Chapter 1 Intro to Formal Lang and Automata
23/31
Automaton An automaton is assumed to operate in
discrete time frame
A finite automaton has a set of states
Its control moves from state to state inresponse to external inputs
8/7/2019 Chapter 1 Intro to Formal Lang and Automata
24/31
Components of an automaton Input file : Contains strings of input
symbols
Storage unit: consists of an unlimitednumber of cells, each capable of holdinga single symbol from an alphabet
Controlunit: can be in any one of a finitenumber of internal states and can change
states in defined manner
8/7/2019 Chapter 1 Intro to Formal Lang and Automata
25/31
Automaton An automaton operates in discrete time
frame
With every automaton, a transitionfunction is associated which gives thenext state in terms of the current state
8/7/2019 Chapter 1 Intro to Formal Lang and Automata
26/31
States of a systemLetus have a code
int a,b,x;
a=5;b=0; x=a+b;
printf(%d%d%d\n,a,b,x);
a=a*3
printf(%d%d%d\n,a,b,x);
b=a+x;printf(%d%d%d\n,a,b,x);
States of thissystem arerepresented by
a tuple (a,b,x)
(15,0,5)
(5,0,5)
(15,20,5)
8/7/2019 Chapter 1 Intro to Formal Lang and Automata
27/31
Transitions from start state to
end state
There are 4 objectsCabbage, Man, Wolf and
Goat on one bank and thereis a boat
All 4 have to cross the riverso that (C,G) or (W,G) arenot left at one place
Man rows the boat andtakes one at a time
Present state
M,C,G,W = J
final state
J= M,C,G,W
transition
8/7/2019 Chapter 1 Intro to Formal Lang and Automata
28/31
Intermediate states
Class assignment
(M
,C,G,W=J=..= (J=M
,C,G,W)
8/7/2019 Chapter 1 Intro to Formal Lang and Automata
29/31
Automaton An automaton can be represented by a
graph in which the vertices give theinternal states and the edges transitions
The labels on the edges show whathappens (in terms of input and output)
during the transitions
8/7/2019 Chapter 1 Intro to Formal Lang and Automata
30/31
Applications of automata Compiler design
Digital design
8/7/2019 Chapter 1 Intro to Formal Lang and Automata
31/31
Pictorial representation of an
automaton: Transition Graphs
q0
Start State
Average
q1
Work hard withlearningWork hard/work
hard withoutlearning
IntermediateState
Good
Workhard
q2
Work hard withintelligent learning
Final State
Excellent