α → β
where α, β ∈ (V u T)+ and |α| ≤ |β|
Where α and β are strings of non-terminals and terminals.
Context-sensitive grammars are more powerful than context-free grammars because there are some languages that can be described by CSG but not by context-free grammars and CSL are less powerful than Unrestricted grammar. That’s why context-sensitive grammars are positioned between context-free and unrestricted grammars in the Chomsky hierarchy.
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
Context-sensitive Language: The language that can be defined by context-sensitive grammar is called CSL. Properties of CSL are :
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}.
18 videos|69 docs|44 tests
|
1. What is a context-sensitive grammar (CSG) and how is it related to context-sensitive language (CSL)? |
2. How is a context-sensitive grammar different from a context-free grammar? |
3. What are some practical applications of context-sensitive grammars and languages? |
4. Can a context-sensitive language be recognized by a finite automaton? |
5. Are all natural languages context-sensitive languages? |
|
Explore Courses for Computer Science Engineering (CSE) exam
|