ACD_Notes MID-1[1]
ACD_Notes MID-1[1]
UNIT 1
1
FINITE AUTOMATA
After going through this chapter, you should be able to understand
Alphabet
Example:
1. If L is an alphabet containing all the 26 characters used in English language, then
L is finiteand nonempty set,and L = {a, b, c, .... , z} .
2. X = { O ,1} is an alphabet.
3. Y = {I , 2 , 3 , ... } is not an alphabet becauseit is infinite.
4. z ={ } is notanalphabet because itis empty.
String
Example :
" xyz " is a string over an alphabet L = {a, b, c, ... , z} . The empty string or null string is
denoted by e .
1.2 FORMALLANGUAGESANDAUTOMATA THEORY
Length of a string
The length ofa string is the number of symbols in that string. If w is a string then its length
is denoted by I w I -
Example:
Example:
1. L = {a,b}, then
L 1 = {a,b},
L 2 = { aa ,. ab , ba, bb} ,
L 3 = {aaa,aab,aba,abb,baa, bab,bba,bbb}
I L 1 1 = 2 = 2 1 (Number ofstrings oflength one),
I L 2 1 = 4 = 2 2 (Number ofstrings oflengthtwo),and
l L 3 = 8 = 23 (Number ofstrings oflengththree)
j
Concatenation of strings
If w1 and w2 are two strings then concatenation of w2 with w 1 is a string and it is denoted by
w1 w2 . In other words, we can say that w1 is followed by w2 and I w1 w2 I = I w1 I + I w2 I -
Automata and Compiler Design
UNIT 2
3.2 FORMALLANGUAGESANDAUTOMATATHEORY
Regular expressions are means to represent certain sets ofstrings in some algebraic
manner and regular expressions describe the language accepted by FA.
If :E is an alphabet then regular expr ession(s) over thiscan be described by followingr ules.
1. Any symbol from :E,e and cl> are regular expressions.
2. If r1 and r2 are two regular expressions then union of these r epresented as r1 u r2 or
, + r2 is also a regular expression
1
Examples:
(1) H '.E = {a, b}, then
(a) a is a regular expression (Usiog r ule I)
(b) b is a regular expression (Usingr ule 1)
(c) a + b isa regular expression (Usingrule2)
(d) b • is a regular expression (Usingrule4)
(e) ab is a regular expression (Usingrule3)
(l) ab + b • is a regular expression (Usiogr ule6)
(2) Fmd rcgUlar expression for the following
(a) Alanguageconsists ofallthewordsover {a,b} endinginb,
(b) A language consists ofall the words over {a, b} endingin bb-
(c) Alanguageconsists of all thewords over {a,b} starting with a and endinginb.
(d) Al anguagec.onsists ofall thewordsover {a,b} having bb as a s ubstring.
(e) Alanguage consists ofall the words over (a, b} ending in aab.
Solution : Let :t = {a,b}, and
All the words over :t = {e, a, b, aa, bb, ab, ba, aaa, ..... } = :E * or (a + b) * or (au b) •
S.62 FORMALLANGUAGESANDA\JTOMATATHEORY
REVIEW QUESTIONS
(i) A regular set accepted bya deterministic finite automaton with n states is accepted to
final state bya detenninistic pda with n states and one pushdovm symbol.
(ii) Everyregular set accepted bya finite automaton with n states is accepted bya
deterministic pda with one state and n pushdown symbols
(iii) IfL is accepted bya deterministic pdaA, then it can be s hown that L is accepted by
a determini stic pdaA which never adds more than one symbol at a time.
(a)(i),(ii)and(iii) (b)(i)and(fo)only
(c)(ii)and(iii)only (d)(i)and(ii)only
24. Match the) e with lhe corres=ndin<>machine:
Language Machine
(i) Regular language (A)Nondetem:!inistipm:lo\'.naulomaton
(ii) DCFL (B)Turing machine
(iii)CFL (C) Detenninistic pushdown automaton
(iv)context-sensitive language (D)(Non)Detenninislicfinife.sjafea=ptor
(v) Recursive language (E)Turing machine that halts
(vi) Recursivelyenumerablel e (F) Linear-bounded automaton
(a)D ACFE B (b)DCAFEB
(c)DCA BEF (d)DCF EA B
25. ThegrdlIUDarthat generates L={ an b11 ci lncl,i = 0) is,
(a) S ➔ aAbl Sc, A ➔ ablaAb (b) S ➔ Al Sc, A ➔ ablaAb
(c)Anyoneofthetwo (d)Noneofthe two.
Automata and Compiler Design
UNIT 3
6
PUSH DOWN AUTOMATA
After going through this chapter, you should be able to understand
6.1 INTRODUCTION
APDA is an enhancement offinite automata(FA). Finite automata with a stack memory can be
viewed as pushdown automata. Addition ofstack memory enhances the capability ofPushdown
automata as compared to finite automata. The stack memory is potentially infinite and it is a data
structure. Its operation is based on last- in - first- out (LIFO). It means, the last object pushed
on the stack is popped first for operation. We assume a stack is long enough and linearly arranged.
We add or remove objects at the left end.
A model of pushdown automata is shown in below figure. It consists of a finite tape, a reading
head, which reads from the tape, a stack memory operating in LIFO fashion.
Input Tape
Reading
.•
Head
.
• Stack
Finite State Control
•
REVIEW QUESTIONS
wR is reverse of W .
Answer:
For Answer refer to example - 1 , Page No : 6.6.
Q3. Obtain a PDA to accept the language L= {·a" b"I n 2. J} by a final state.
Answer:
For Answer refer to example - 2 , Page No: 6.9.
Q4. Obtain a PDA·to accept the language L(M) = { wjw e(a +b) ° and n. (w) =11,(w)}.
Answer:
For Answer refer to example - 3 , Page No : 6.12.
QS. Obtain a PDA to accept a string of balanced parentheses. The parentheses
to be considered are ( , ) , I. ].
Answer:
For Answer refer to example - 4, Page No: 6.15.
Q6. Obtain a PDAto accept the language L = { l>jw e (a, b)•and nu (w) >n,(w)}.
Answer:
For Answer refer to example • 5 , Page No : 6.17.