Peter Linz K.L.P Mishra Ullman
Peter Linz K.L.P Mishra Ullman
P Mishra Ullman
An
automaton is an abstract model of a digital computer. It has a mechanism of reading input. It may have temporary storage device, which will store symbols. The automation has a control unit , which can be in any one of a finite number of internal states and which can change state in some defined manner.
Input
st storage
Control Unit
output
Eg:
A binary adder is an integral part of any general purpose computer. Such an adder takes two bit strings representing numbers and produces their sum as output. bi
0 1 1 No carry 0 Carry
ai
0 1
O No carry 1 No carry
ai bi
di
Adder
The inputs are the bit pairs (ai,bi), the output will be the sum bit di. We represent the automation by a graph now labeling the edges (ai,bi)/di
(1,0)/0 (1,1)/1
No carry
(0,0)/1
carry
Deterministic
automata: In this each move is uniquely determined by the current configuration. If we know the internal state, the input and the contents of the temporary storage, we can predict the future behavior. Of the automation exactly. Nondeterministic automata: At each point, Nondeterministic automation may have several possible moves, so we can only predict a set of possible actions.
Where Q is a finite set of internal states is a finite set of symbols called the input alphabet :Q X Q is a total function called the transition function, q0 Q is the initial state F Q is a set of final states.
L=
{a^n b : n>=0}
q0
a a,b
q1
a,b
q2
Find
the dfa that recognizes the set of all strings on ={a,b} starting with the prefix ab
a b a,b
a,b
= { awa: w {a,b}*}
b a b b a a
a,b
Nondeterminism means a choice of moves for an automaton. Rather than prescribing a unique move in each situation, we allow set of possible moves. A nfa is defined by the quintuple M= (Q,,, q0, F) Where Q is a finite set of internal states is a finite set of symbols called the input alphabet :Q X ( { })-> 2^Q is a total function called the transition function, q0 Q is the initial state F Q is a set of final states.
Current
q2
q3
Q4
a
q5
0
q0 q1
0,1
q2
State/ Symbol q0 q1 q2
a q0, q1 q0
b q2 q1 q0, q1
State/ symbol q0 q1 q2
q3
a q0,q1 q2 q3
b q0 q1 q3 q2
Regular
expression involves a combination of strings of symbols from alphabet , parentheses, and the operators +, . , *. + denotes union . denotes concatenation * denotes Star closure
The language L(r) denoted by any regular expression r is defined by the following rules. 1. is a regular expression denoting the empty set. 2. ,is a regular expression denoting {} 3. For every a , a is a regular expression denoting {a}. If r1 and r2 are regular expressions, the 4. L(r1+r2)= L(r1) U L(r2) 5. L(r1.r2) = L(r1) L(r2) 6. L((r1))= L(r1) 7. L(r1*)= (L(r1))*
Exhibit
the language L(a*.(a+b)) in set notation. L(a*.(a+b))= L(a*)L(a+b) = (L(a))*(L(a)U L(b)) = {, a,aa,aaa,}{a,b}
The
expression r=(aa)*(bb)*b It denotes the language L(r) = {a^2n b^2m+1: n>=0, m>=0}
For ={0,1}, give a regular expression such that L(r) = {w * : w has at least one pair of consecutive zeros} r= (0+1)*00(0+1)*
language is regular if it is accepted by some DFA. Because of the equivalence of nfa and dfa , a language is also regular if it is accepted by some nfa. One way of describing languages is by means of certain simple grammar. Grammars are often an alternative way of specifying languages .
grammar G=(V,T,S,P) is said to be right linear if all productions are of the form A-> xB A-> x Where A,B V, and x T*. A grammar is said to be left linear if all productions are of the form A-> Bx A-> x regular grammar is one that is either right linear or left linear.
The grammar G1=({S}, {a,b}, S, P1) with P1 is given as S abS a Is right linear. The grammar G2= ({S,S1,S2}, {a,b}, S, P2) with productions S S1ab S1 S1ab S2 S2 a Is left linear. Both G1 and G2 are regular grammars. The sequence SabSababSababa is a derivation with G1. From this single instance it is easy to conjecture that L(G1) is the language denoted by the regular expression r=(ab)*a. In a similar way we can see that L(G2) is the regular language L(aab(ab)*).
The
grammar G=({S,A,B},{a,b},S,P) with productions S A A aB/ B Ab Is not regular. Although every production is either in right linear or left linear form, the grammar itself is neither right-linear nor left linear, and therefore is not regular.
Construct
a finite automaton that accepts the language generated by the grammar Vo aV1
V1
abVo b
Where
Vo is a start variable
Vo
a b a
V1
vf
Conversion
of t into production (qi,aj)= qk We put in P the production qi aj qk Construct a right linear grammar for L(aab*a). The transition function for an nfa, together with the corresponding grammars productions, is given in previous Qus
Not
all languages are regular , Production in a regular grammar are restricted. A grammar G=(V,T,S,P) is said to be context free if all productions in P have the form A->x Where A V and x (V U T)* A language L is said to be Context free if and only if there is a CFG G such that L=L(G).
The
: n>=0}
derivation is said to be leftmost if in each step the leftmost variable in a sentential form is replaced. If in each step the right most variable is replaced , we call the derivation rightmost. Consider the grammar with productions S aAB AbBb Ba
Then
Second
tree. Let G=(V,T,S,P) be a CFG. An ordered tree is a derivation tree for G if and only if it has the following properties. 1. The root is labeled S 2. Every leaf has a label from TU{} 3. Every interior vertex( not lf a vertex has label AV, and its children are labeled (from left to right) a1,a2,a3.an, then P must contain a production of the form A a1,a2,a3..an
5.
A leaf labeled has no siblings, that is , a vertex with a child labeled can have no other children.
Partial derivation tree: A tree has properties 3,4,5, but in which 1 does not necessary hold and in which property 2 is replaced by- Every leaf has a label from VUTU{} is said to be Partial derivation tree.
For abbbb
b B b A
context free grammar G is said to be ambiguous if there exists some w L(G) that has at least two distinct derivation trees. Eg Show that grammar with productions S aSbSS is ambiguous. The sentence aabb has the two derivation S trees.
a a S S b
Eg:
consider a grammar G=(V,T,E,P) V={E,I} T={a,b,c,+,*,(,)} And productions E I E E+E EE*E E(E) I abc
For
E I
E I
E E E E I
* + E