Flat 1
Flat 1
Module 1
Introduction
1.1 Alphabet
Grammar
Note –
S → b/aA
A → c/bS
S ⇒ aA ⇒ abS,
A ⇒ bS ⇒ baA
Derivation
● Type 0 grammar -
Example :
bAa → aa
P→p
● Type 1 grammar -
Key takeaway :
● Where the number of symbols in V is equal to or less than
T
Example :
S → AT
T → xy
A→a
● Type 2 grammar -
A→α
Key takeaway :
Example :
A → aBb
A→b
B→a
● Type 3 grammar -
V → T*V / T*
Example :
A → xy
Key takeaway :
Additional operators are recognized by unix. These operators are used for
convenience only.
A Review (supplemental)
Recall the example of designing a vending machine selling 20-dolllar food
packs in Figure 1.3.2.What abstract concepts are involved in the
design? ⇒ See the definition next.
Figure Recall the example
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 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-
● More intuitive!
Some properties of NFA’s (see Fig. 2.6 for the illustration) ---
The following table lists the differences between DFA and NDFA.
DFA NDFA
The transition from a state is to a single The transition from a state can be to
particular next state for each input multiple next states for each input
symbol. Hence it is called deterministic. symbol. Hence it is called non-
deterministic.
Empty string transitions are not seen in NDFA permits empty string
DFA. transitions.
Constructing an FA from an RE
● If the operand is epsilon, then our FA has two states, s0 (the start
state) and sF (the final, accepting state), and an epsilon transition
from s0 to sF.
● If the operand is null, then our FA has two states, s0 (the start state)
and sF (the final, accepting state), and no transitions.
Given FA for R1 and R2, we now show how to build an FA for R1R2, R1|
R2, and R1*. Let A (with start state a0 and final state aF) be the machine
accepting L(R1) and B (with start state b0 and final state bF) be the
machine accepting L(R2).
For each pair of states i and j in F2, there is a transition from state i to
state j on input x if there exists a state k that is reachable from state i via
epsilon transitions in F1, and there is a transition in F1 from state k to
state j on input x.
Pick DFAs recognizing the two languages and use the cross-
product construction to build a DFA recognizing their union or
intersection. See Sipser Theorem 1.25. Also see Sipser 1.45
for another way to do union.
Set complement
String reversal
Homomorphism
Notice that regular languages are not closed under the subset/superset
relation. For example, 0 1 is regular, but its subset {O 1 : n >= 0} is not
* * n n