Formal Language and Automata
Theory
Shiplu Das
Computer Science and Engineering
Brainware University 1
Course Information
• Course Name: Formal Language and Automata Theory
• Course Code: PCC-CS503
• Contact: 3L
• Credits: 3
• No. of Lectures: 36
2
Communication Process
3
Communication Process
4
Communication Process
5
Communication Process
6
Communication Process
7
Langauage
• Alphabets {A,B,C.....Z}
• Words
Grammar
• Sentences {Let us discuss formal language}
• Paragraphs.
8
Representation of Grammar
• A grammar G can be formally written as a 4-tuple (N, T, S, P)
where −
N is a set of variables or non-terminal symbols.{1,2,3..E,T,F,V...}
T is a set of terminal symbols.{x,y,z...,+,-,*,/...}
S is a special variable called the Start symbol
P is Production rules for Terminals and Non-terminals. A
production rule has the form α → β
9
Example
• Grammar G1 −({S, A, B}, {a, b}, S, {S → AB, A → a, B → b})
S, A, and B are Non-terminal symbols.
a and b are Terminal symbols.
S is the Start symbol.
Productions, P : S → AB, A → a, B → b
10
Example
• Grammar G2 −({A, B}, {a, b, c}, B, {A → B, A → a, A→c,
B → b, B→A})
A, and B are Non-terminal symbols.
a , b and c are Terminal symbols.
B is the Start symbol.
Productions, P : A → B, A → a, A→c,B → b, B→A
11
Example
• Grammar G2 −({A, B}, {a, b, c}, P, {A → B, A → a, A→c,
B → b, B→A})
Wrong Grammar
12
Derivations Strings from a Grammar
Example
• Let us consider the grammar −
G2 = ({S, A}, {a, b}, S, {S → aAb, aA → aaAb, A → b } )
Some of the strings that can be derived are −
S ⇒ aAb (S → aAb)
⇒ aaAbb (aA → aAb)
⇒ aabbb (A → b) Accepted Strings
13
Derivations Strings from a Grammar
Example
G={S → aS , S → B, B → b and B → bB} where S is Start
symbol.
S → B → b (Accepted)
S → B → bB → bb (Accepted)
S → aS → aB → ab (Accepted)
S → aS → aaS → aaB → aab(Accepted)
S → aS → aB → abB → abb (Accepted)
14
Derivations Tree
• A derivation tree is an ordered rooted tree that graphically
represents the semantic information a string derived from
grammar.
15
Derivations Tree
Representation Technique
• Root vertex
• Vertex
• Leaves vertex
The root node is always a node indicating start symbols.
The leaf node is always terminal nodes.
The interior nodes are always the non-terminal nodes.
16
Derivations Tree
17
Start Symbol
Non Terminal
Terminal
Derivations Tree
18
S
b
a
A
b
Derivations Tree
19
S
b
a
A
b
S-Start Symbol
A-Vertex
a,b,d-Leaves vertex
Derivations Tree
Example1:
Let a G1 {N,T,P,S} be
N = {S}, T = {b,c,d}, Starting symbol = S, P = {S → AA
,A→bc,A→d}
One derivation tree from the above string is “bcd”
S → AA
→ bcA (A→bc)
→ bcd (A→d)
→ bcd Accepted
20
Derivations Tree
S → AA
→ bcA
→ bcd
21
S
Derivations Tree
S → AA
→ bcA
→ bcd
22
S
A A
Derivations Tree
S → AA
→ bcA
→ bcd
23
S
A A
b c
Derivations Tree
S → AA
→ bcA
→ bcd
24
S
A A
b c d
Derivations Tree
S → AA
→ bcA
→ bcd
25
S
A A
b c d
Derivations Tree
Example:
Let a G1 {N,T,P,S} be
N = {S}, T = {a, b}, Starting symbol = S, P = S → SS | aSb | c
One derivation from the above string is “acbc”
S → SS
→ aSbS (S→aSb)
→ acbS (S→c)
→ acbc (S→c)
26
Automata
• The term "Automata" is derived from the Greek word "αὐτόματα" which
means "self-acting".
• An automaton (Automata in plural) is an abstract computing device
which follows a predetermined sequence of operations automatically.
27
Thank You
28

PCC-CS503.pptx