You are on page 1of 11

Department of Computer and Science Engineering (CSE)

UNIVERSITY INSTITUTE OF
ENGINEERING
COMPUTER SCIENCE
ENGINEERING
Bachelor of Engineering
Theory of Computation (CST-353)

Topic: Undecidability
DISCOVER . LEARN .
University Institute of Engineering (UIE) EMPOWER
Department of Computer and Science Engineering (CSE)

Learning Objectives & Outcomes


Objective:
• To understand the concept of Context Sensitive Language.

Outcome:
Student will understand the
• To know about Context sensitive language and grammar.
• Relation between languages of classes.

University Institute of Engineering (UIE)


Department of Computer and Science Engineering (CSE)

Context-sensitive Grammar (CSG) and Language (CSL)

Context-Sensitive Grammar –
A Context-sensitive grammar is an Unrestricted grammar in
which all the productions are of form –

University Institute of Engineering (UIE)


Department of Computer and Science Engineering (CSE)

• Context-sensitive grammar has 4-tuples. G = {N, Σ, P, S},

Where
N = Set of non-terminal symbols
Σ = Set of terminal symbols
S = Start symbol of the production
P = Finite set of productions

All rules in P are of the form α1 A α2 –> α1 β α2

University Institute of Engineering (UIE)


Department of Computer and Science Engineering (CSE)

Example –
Consider the following CSG.
S → abc/aAbc
Ab → bA
Ac → Bbcc
bB → Bb
aB → aa/aaA

What is the language generated by this grammar?


Solution:
S → aAbc
→ abAc
→ abBbcc
→ aBbbcc
→ aaAbbcc
→ aabAbcc
→ aabbAcc
→ aabbBbccc
→ aabBbbccc
→ aaBbbbccc
→ aaabbbccc
The language generated by this grammar is {anbncn | n≥1}.

University Institute of Engineering (UIE)


Department of Computer and Science Engineering (CSE)

Relation between languages of classes


In order to understand the relationship between the
grammar and language let us understand what is language
generated by grammar.

Language generated by grammar


•The grammar is S-> aSb| epsilon.
•In this grammar, by using S-> epsilon , we can generate
epsilon.
•Therefore, epsilon is part of L(G).
•Similarly, by using S=>aSb=>ab, ab is generated.
•Similarly, aabb can also be generated.

University Institute of Engineering (UIE)


Department of Computer and Science Engineering (CSE)

• Therefore, the result is as follows −


• L(G) = {anbn, n>0}
• In language L(G) which is discussed above, the condition
n =0 is taken to accept the epsilon.
• Consider the grammar given below
• S -> aSa | bSb | a |b
• Now, let us find out what language is generated by the
above grammar over the alphabet {a,b}.

University Institute of Engineering (UIE)


Department of Computer and Science Engineering (CSE)

• Explanation
• Using S->a and S->b,
• a and b can be generated.
• Similarly by using S->aSa
• ->aba
• aba can be generated.
• Other strings which can be generated from grammar are
as follows −
• a,b,aba,bab,aaa,bbb,ababa,.....
• Therefore, the language generated for the given grammar
over the alphabet {a,b} is the set of all odd length
palindromes.

University Institute of Engineering (UIE)


Department of Computer and Science Engineering (CSE)

Outcomes
• To know about Context sensitive language and
grammar.
• Relation between languages of classes.

9
University Institute of Engineering (UIE)
Department of Computer and Science Engineering (CSE)

FAQ
1. Convert the given expression to PDA
I --> a | b | Ia | Ib | I0 | I1
2. Design a PDA for accepting a language {L= anbn | n >=1}
3. What is the language generated by the grammar
G=(V,T,P,S) where P={S->aSb, S->ab}?

University Institute of Engineering (UIE)


Department of Computer and Science Engineering (CSE)

REFERENCES
• Sipser,” Theory Of Computation, Cengage Learning.
• Daniel I.A. Cohen, “Introduction to computer Theory”, John
Wiley.

University Institute of Engineering (UIE)

You might also like