Alphabet, Language, Grammar, and Derivation: Definitions and Relationships in Formal Language Theory

Alphabet, Language, Grammar, and Derivation: Definitions and Relationships in Formal Language Theory

Verified Sources
Sep 12, 2026

In formal language theory, we study how strings over symbols can be generated or recognized. Four foundational notions—Alphabet , Language , Grammar , and Derivation—connect in a precise way:

Here, a grammar generates strings via derivations; the set of all strings that can be derived forms the language. This relationship is central to how formal grammars specify languages.

Formal Languages: Alphabet, Strings, Grammar, Derivation (Intro)

Core definitions (with roles)

  1. Alphabet (Σ): The basic symbol inventory.

    • Example: Σ={a,b}\Sigma=\{a,b\}
  2. Strings and Σ\Sigma^{*}:

    • A string is any finite sequence of symbols from Σ\Sigma (including the empty string).
    • Σ\Sigma^{*} denotes the set of all strings over Σ\Sigma.
  3. Language (L): A subset of Σ\Sigma^{*}.

    • Example: L={anbnn0}L=\{a^n b^n \mid n\ge 0\} over Σ={a,b}\Sigma=\{a,b\}
  4. Grammar (G): A formal mechanism that uses production rules to generate strings.

    • Typically written G=(V,Σ,R,S)G=(V,\Sigma,R,S) where:
      • VV = variables (nonterminals),
      • Σ\Sigma = terminals (alphabet symbols),
      • RR = productions (rules),
      • SS = start symbol.
  5. Derivation (⇒): The process of repeatedly applying productions starting from SS to reach a string.

    • Notation: SwS \Rightarrow w for one step; SwS \Rightarrow^{*} w for zero or more steps.

Relationship between the four terms

1) Alphabet Σ\Sigma sets the “universe” of strings

Once Σ\Sigma is fixed, every string relevant to the theory is an element of Σ\Sigma^{*}. Every language is a selection from this universe.

Example: Let Σ={0,1}\Sigma=\{0,1\}. Then 010Σ010 \in \Sigma^{*}.


2) Language LL is a set of strings over Σ\Sigma

A language is defined as a subset of Σ\Sigma^{*}:

LΣ.L \subseteq \Sigma^{*}.

Example:

  • Σ={0,1}\Sigma=\{0,1\}
  • L={wΣw ends with 1}L=\{w \in \Sigma^{*} \mid w \text{ ends with } 1\}
    Then 001L001\in L, but 000L000\notin L.

3) Grammar GG generates (defines) the language

A grammar specifies which strings belong to the language by providing rules for building them.

A string ww over Σ\Sigma belongs to the language of GG exactly when there exists a derivation from the start symbol:

wL(G)iffSw.w \in L(G) \quad \text{iff} \quad S \Rightarrow^{*} w.

4) Derivation is the “witness” that a string is in the language

Membership is not just conceptual; derivations provide a constructive proof:

  • Start with SS (the grammar’s start symbol).
  • Apply productions to rewrite variables into other variables/terminals.
  • After finitely many steps, if the result contains no variables (only terminals), you obtain a generated string.

Example derivation: from grammar to a string in the language

  1. 1
    Step 1

    Let Σ={a,b}\Sigma=\{a,b\}.

  2. 2
    Step 2

    Use GG with variables V={S}V=\{S\}, start symbol SS, and productions R={SaSb,  Sab}R=\{S\to aSb,\; S\to ab\}. Terminals are the symbols in Σ\Sigma.

  3. 3
    Step 3

    Begin with SS.

  4. 4
    Step 4

    Apply SaSbS\to aSb to expand: SaSbS \Rightarrow aSb; then apply SabS\to ab inside: aSba(ab)baSb \Rightarrow a(ab)b.

  5. 5
    Step 5

    The string aabbaabb has no variables, so SaabbS \Rightarrow^{*} aabb. Therefore aabbL(G)aabb \in L(G).

Derivation trace (the same example, shown clearly)

Using GG:

  • SaSbS \to aSb
  • SabS \to ab

Derivation for aabbaabb:

SaSba(ab)b=aabb.S \Rightarrow aSb \Rightarrow a(ab)b = aabb.

A grammar may generate many strings; the language is the set of all strings for which such derivations exist.

Pro Tip: Think “grammar = generator; derivation = proof; language = set of results.”

If you can produce a derivation SwS \Rightarrow^{*} w, then ww belongs to the language defined by the grammar.

Warning: Derivation steps are formal rewrites, not general substitutions.

In derivations, you may only replace variables using the grammar’s production rules. Terminals are not typically replaced, unless your grammar explicitly allows it via productions (usually terminals appear only on the right-hand side as fixed symbols).

How a string becomes part of a language

Alphabet

1. Fix Σ

Choose the set of symbols that can appear in strings."

Language

2. Define a set L

A language is a subset of Σ\Sigma^{*}."

Grammar (production rules)

3. Specify G

Define rules that generate strings."

Derivation

4. Produce w

Show SwS \Rightarrow^{*} w; then wL(G)w \in L(G)."

Concept mapping: term → what it constrains/produces

A quick visual of how each concept contributes

Common clarifications

Terminology: Alphabet, Language, Grammar, Derivation

1 / 5
Question · Term

Alphabet (Σ)

Click to reveal
Answer · Definition

Finite set of symbols used to build strings.

Knowledge Check

Question 1 of 3
Q1Single choice

Let GG be a grammar with start symbol SS. Which condition is equivalent to “ww belongs to the language generated by GG”?