Professional Documents
Culture Documents
Problem 1:
Design a DFA with ∑ = {a, b} accepts those string which starts with a.
Solution:
Transition System
Note: If the input begins with a, it will be reached in the final state.
Problem 2:
Design a DFA with ∑ = {a, b} accepts those string which starts with ab.
Solution:
Transition System
Problem 3:
Design a DFA with ∑ = {a, b} accepts those string that contains with a.
Solution:
Transition System
● Write LLG
S → B1 | C0 | A0
A → A1 | D0 | C0 | B1|0
B → B1 | D1 | 1
C → A0
D →ε
The theorems of the form “if certain languages are regular and a language L is
formed from them by certain operations, then L is also regular” are called closure
properties of the regular languages. Following are the closure properties of regular
languages.
1. Regular expressions are closed under union operation
2. Regular expressions are closed under intersection operation
3. Regular expressions are closed under complementation operation
For example,
Consider the CFG,
E→I
E→E+E
E→E*E
E → (E)
E → E * (E) (E → (E))
E → E * (E + E) (E → E + E)
E → E * (I + E) (E → I)
This derivation is neither left sentential form nor right sentential form. At the last
step, middle E is replaced.
E→I*E (E → I)
E→a*E (I → a)
Example of right sentential form, consider E * (E + E)
E→E*E
E → E * (E) (E → (E))
E → E * (E + E) (E → E + E)
The derivations in a CFG can be represented using trees. Such trees representing
derivations are called derivation trees. Derivation means replacing any nonterminal
by a proper production rule.
A derivation tree also called as a parse tree for a CFG, G = (V, T, P, S) is a tree
satisfying the following conditions
● All the leaf nodes of the tree are labelled by terminals of the grammar
● The root node of the tree is labelled by the start symbol of the grammar
● The interior nodes are labelled by the nonterminal
● If an interior node has a label A, and has n descendants with labels X 1, X2,
…., Xn from left to right, then there must exist production rule A→ X 1X2
….Xn in the
grammar.
● A vertex n is a leaf if its label is a
E→E+E
E→E*E
E → id
E → id + E (E → id)
E → id + E * E (E → E * E)
E → id + id * E (E → id)
E → id + id * id (E → id)
We can implement the parse tree of the above CFG using leftmost derivation as
S→aABe
S→abBe
(A→b)
S→abde (B→d)
A B
a b d e
Definition
Where,
1. Transition Diagram
2. Transition Table
3. Instantaneous descriptions using move relation
Where X/Y specify that X is to be replaced by Y in the tape cell scanned, and R specify that the
tape head is to be moved one cell right and an arrow from q to p, specify that state is to be
changed from q to p.
Where X/Y specify that X is to be replaced by Y in the tape cell scanned, and L specify that the
tape head is to be moved one cell left and an arrow from q to p, specify that state is to be changed
from q to p.
Transition table
A transition table is a tabular representation of a transition function δ that takes two arguments
and returns a state, replace symbol and tape direction. The rows of the table correspond to the
states and the columns correspond to the input symbols along with B (blank symbol).
For example,
The arrangement of a Turing machine depends on the present state of the finite control and the
next input symbol, which depends on the string written on an input tape at that instance of time.
If the current state is q0 and the next input symbol appearing on the tape is x and if the Turing
machine changes its state to state q1 in the right direction and replaces the input symbol by B.