Math 2.0

Computer science Definition

Context-sensitive language

Builds on Formal grammarFormal languageContext-free language

Definition

A context-sensitive grammar is a formal grammar G=(N,Σ,P,S)G = (N, \Sigma, P, S) in which every rule has one of the following forms:

  1. αAβ→αγβ\alpha A \beta \to \alpha \gamma \beta, where A∈NA \in N, α,β∈(N∪Σ)∗\alpha, \beta \in (N \cup \Sigma)^* and γ∈(N∪Σ)∗\gamma \in (N \cup \Sigma)^* is nonempty;
  2. S→εS \to \varepsilon, allowed only if SS does not occur on the right side of any rule.

A formal language LL is context-sensitive if L=L(G)L = L(G) for some context-sensitive grammar GG.

Remarks

Equivalently, LL is context-sensitive if it is generated by a noncontracting grammar, one whose rules α→β\alpha \to \beta satisfy ∣α∣≤∣β∣\abs{\alpha} \le \abs{\beta}, again with the exception S→εS \to \varepsilon. Example: {anbncn:n≥1}\set{a^n b^n c^n : n \ge 1} is context-sensitive; the rules S→aSBCS \to aSBC, S→aBCS \to aBC, CB→BCCB \to BC, aB→abaB \to ab, bB→bbbB \to bb, bC→bcbC \to bc, cC→cccC \to cc form a noncontracting grammar for it. Non-example: a rule AB→AAB \to A is not allowed, since it shortens the string and is not of the form of clause 2. Every context-free language is context-sensitive, and every context-sensitive language is decidable.

Reading path

To understand this page from the ground up, read these 4 pages in order. The foundations come first.

Show the path as a graph
Each page uses the pages above it. The colour of the bar on a box shows how strong the evidence is, and the box also gives it as text. The list has the same pages.
  • no evidence level
  1. Context-free language concept
  2. Formal grammar concept
  3. Formal language concept
  4. Context-sensitive language definition

Further reading

  1. Web https://en.wikipedia.org/wiki/Context-sensitive_language
About this page
Tag9YGQ5X06J6
URIm2://9YGQ5X06J6
Kinddefinition
WritingW0 stub
MSC68Q45, 68Q42
DefinesContext-sensitive language
UsesFormal grammar, Formal language, Context-free language
Changed3 November 2026

Markdown · JSON · Edit on GitHub

What this page needs for W1

  • an inventory row: the row of the inventory that the node accounts for (0 of 1)
  • a source with a locator (0 of 1)

The writing levels say how complete the text of a page is. They do not measure its truth.

What links here

No page links to this page yet.