REW

Is A -> Aa Unit Production?

Published Aug 29, 2025 3 min read
On this page

No, A -> aA is not a unit production. In the context of formal language theory and context-free grammars (CFG), a unit production is a rule of the form A→Bcap A right arrow cap B 𝐴→𝐵 , where both Acap A

𝐴

and Bcap B

𝐵

are single, non-terminal symbols. The production A→aAcap A right arrow a cap A

𝐴→𝑎𝐴

is not a unit production because the right-hand side (RHS) contains a terminal symbol (aa

𝑎

) and a non-terminal symbol (Acap A

𝐴

), making it a different type of production.

What is a unit production?

A unit production is a special type of production rule in a Context-Free Grammar (CFG) where a single non-terminal directly derives another single non-terminal.

  • **Form:**A→Bcap A right arrow cap B

    𝐴→𝐵

  • **Where:**Acap A

    𝐴

    and Bcap B

    𝐵

    are non-terminal symbols.

  • Purpose: Unit productions represent a simple redirection in the derivation process. They are often targeted for removal during grammar simplification to make parsing more efficient, since they don't produce any new terminal symbols.

What is the production A→aAcap A right arrow a cap A

𝐴→𝑎𝐴

?

The production A→aAcap A right arrow a cap A

𝐴→𝑎𝐴

is a left-recursive production.

  • **Form:**A→αAcap A right arrow alpha cap A

    𝐴→𝛼𝐴

    where αalpha

    𝛼

    is a string of terminals and/or non-terminals.

  • Where: The non-terminal on the LHS is also the leftmost symbol on the RHS.

  • Purpose: This type of production is used to generate a series of symbols. In this specific case, A→aAcap A right arrow a cap A

    𝐴→𝑎𝐴

    can be used to generate any number of the terminal symbol 'aa

    𝑎

    '. For example, a derivation could proceed as follows:

    • A⟹aA⟹aaA⟹aaacap A ⟹ a cap A ⟹ a a cap A ⟹ a a a

      𝐴⟹𝑎𝐴⟹𝑎𝑎𝐴⟹𝑎𝑎𝑎

      (if there is also a rule A→acap A right arrow a

      𝐴→𝑎

      )

Comparison: Unit production vs. left-recursive production

Feature Unit Production (A→Bcap A right arrow cap B 𝐴→𝐵 ) Left-Recursive Production (A→aAcap A right arrow a cap A 𝐴→𝑎𝐴 )
Right-hand side A single non-terminal symbol. Contains at least one terminal and/or non-terminal symbol, with the same non-terminal as the LHS as the leftmost symbol.
Action Replaces one non-terminal with another. Generates a terminal symbol and continues the derivation using the same non-terminal.
Purpose Simplification and removal for parser efficiency. Useful for generating strings of repeated symbols. Can be problematic for some parsing techniques and is often transformed to eliminate left recursion.

Significance in grammar simplification

In the process of simplifying a CFG to a normal form like Chomsky Normal Form (CNF), both unit productions and productions with left recursion must be addressed.

  1. Eliminating unit productions: This is a standard procedure in CFG simplification. It involves finding all pairs of non-terminals (A,B)open paren cap A comma cap B close paren

    (𝐴,𝐵)

    where A⟹*Bcap A ⟹ raised to the * power cap B

    𝐴⟹*𝐵

    (meaning Bcap B

    𝐵

    can be derived from Acap A

    𝐴

    through a series of unit productions) and then adding new rules to bypass the intermediate non-terminal(s).

  2. Removing left recursion: This is another important step, particularly for predictive parsers which cannot handle it. A common technique is to transform left-recursive rules into a set of non-left-recursive rules, often introducing a new non-terminal. For example, the rules:A→Aα∣βcap A right arrow cap A alpha divides beta

    𝐴→𝐴𝛼∣𝛽

    could be converted to:A→βA′cap A right arrow beta cap A prime

    𝐴→𝛽𝐴′

    A′→αA′∣ϵcap A prime right arrow alpha cap A prime divides epsilon

    𝐴′→𝛼𝐴′∣𝜖

    where αalpha

    𝛼

    does not begin with Acap A

    𝐴

    . In your example, A→aAcap A right arrow a cap A

    𝐴→𝑎𝐴

    , the rule is already in a simple form that doesn't need this complex transformation, but it is still a form of left recursion.

Enjoyed this article? Share it with a friend.