languages

Definition

Context-Sensitive Grammar (Type-1)

A grammar is called context-sensitive (Type-1) if every production rule in is context-sensitive.

In words: a single non-terminal symbol may be replaced by a nonempty string, but only in its surrounding context.

Example

A grammar for

Consider the following context-sensitive grammar:

It generates the language , which is context-sensitive but not context-free.

Here is one derivation of .

  1. Start with the start symbol:
  1. Apply once. This adds one on the left and one and one on the right:
  1. Apply to the remaining . This produces the base word:
  1. Apply to the substring :
  1. Apply to the remaining :