You are on page 1of 9

Construction of DFA

Problem 1:

Design a DFA with ∑ = {a, b} accepts those string which starts with a.

Solution:

The strings accepted by the DFA are

L = {a, ab, aa, abb, aba, …….}

Transition System

In state q0, if we read a, we will be in state q 1, then we read either a or b, we will


reach state q1 which is the final state.

In state q0, if we read b, we will go to q2 state, then if we read either a or b, we


will reach q2 state. Here, q2 is the rejected state.

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:

The strings accepted by the DFA are


L = {ab, abb, aba, abab, abba, …….}

Transition System

In state q0, if we read a, we will be in state q 1, then we read b, we will be in state


q2, then we read either a or b, we will reach state q 2 state which is the final state.
In state q1, we read a, we will go to q3 state.

In state q0, if we read b, we will go to q3 state, then if we read either a or b, we


will reach q3 state. Here, q3 is the rejected state.

Problem 3:

Design a DFA with ∑ = {a, b} accepts those string that contains with a.

Solution:

The strings accepted by the DFA are

L = {a, ab, ba, aa, aba, abab, abba, …….}

Transition System
● Write LLG
S → B1 | C0 | A0

A → A1 | D0 | C0 | B1|0

B → B1 | D1 | 1

C → A0

D →ε

Here D → ε , we can rewrite it as S


→ B1 | C0 | A0
A → A1 | C0 | B1|0 (D0 → ε0 → 0)
B → B1 | 1 (D1 → ε1 → 1)
C → A0

Closure properties of Regular Sets

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

4. Regular expressions are closed under subtraction


5. Reversal of regular language is regular
6. Closure of a regular language is regular
7. Regular expressions are closed under concatenation operation
8. Regular expressions are closed under homomorphism of a regular language
is regular
9. Regular expressions are closed under inverse homomorphism of a
regular language is regular

For example,
Consider the CFG,
E→I

E→E+E

E→E*E

E → (E)

Obtain the sentential form of E * (I + E)


Derivation:
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.

Example of left sentential form, consider a * E


E→E*E

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)

Derivation Tree or Parse Tree

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

For example, consider the production rule

E→E+E

E→E*E

E → id

Construct the derivation tree for the string id + id


* id Left most derivation:
E→E+E

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)

We can draw the bottom up parse tree of the above derivation as

A B

a b d e

Turing Machine (TM)


Type 0 grammar is used in the Turing machine. It accepts a recursively enumerable language
(REL). A Turing machine can be considered as a finite control machine connected to the R/W
head. The tape is divided into a number of cells. The machine checks the present symbol under
the R/W head on the tape and the present state of an automaton in one move.
The basic structure of Turing Machine as

A Turing machine is made up of finite control, an input tape


that is divided into cells and a tape head that scans one cell at a
time. It can be moved to left as well as right, initially the n cells
hold the input of length n, whereas the remaining infinity of cells
hold a special symbol called Blank symbol B. Only one symbol can
be stored by each cell.

Definition

A Turing machine M is a 7 – tuple system.


M = (Q, Σ, Γ, δ, q0, B, F)

Where,

Q is finite set of states of Turing Machine

Σ is set of input symbol excluding Blank symbol

Γ is finite set of symbols called as tape

symbols q0 is the initial state

B is the Blank symbol F is a set of Final states δ defines a

mapping from Q × Γ to Q × Γ × {L,R}

Representation of Turing Machine

A Turing machine can be represented by three ways

1. Transition Diagram
2. Transition Table
3. Instantaneous descriptions using move relation

Transition Diagram A transition diagram of the next move function δ of a TM is a graphical


representation consisting of a finite number of nodes and directed labeled arcs between the
nodes. Each node represents a state and a label on an arc from one state to a state represents the
information about the required input symbol, the transition and the action on the part of the
control of TM.

We can represent a move δ (q, X) = (p, Y, R) graphically as

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,

Consider the transition diagram

Instantaneous descriptions using move relation

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.

You might also like