0% found this document useful (0 votes)
5 views

Lecture

Great books

Uploaded by

Vicky Sharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Lecture

Great books

Uploaded by

Vicky Sharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

Introduction to Formal Grammars and Chomsky

Hierarchy
Lecture 1 - Module I: Languages and Automata

Dr. Mayank Kumar Jain, Associate Professor

06 January 2025
Objectives of the Lecture

▶ Understand the concept of formal grammars.


▶ Explore the Chomsky Hierarchy and its significance.
▶ Learn about the classification of grammars and languages.
What is a Formal Grammar?

▶ Definition: A formal grammar is a set of rules that define the


structure of strings in a language.
▶ Components:
▶ Terminal Symbols (T): The basic symbols from which strings
are formed.
▶ Non-terminal Symbols (V): Symbols used to represent
patterns in the language.
▶ Start Symbol (S): The initial non-terminal symbol.
▶ Production Rules (P): Rules that describe how terminal and
non-terminal symbols combine.
Example of a Formal Grammar

Example Grammar:
▶ Terminals (T): {a, b}
▶ Non-terminals (V): {S}
▶ Start Symbol: S
▶ Productions:
▶ S → aSb
▶ S → ϵ (epsilon)
Language Generated: {”ab”, ”aabb”, ”aaabbb”, ...}
Introduction to Chomsky Hierarchy

▶ Type 0: Unrestricted Grammars (All languages that can be


generated by a Turing Machine).
▶ Type 1: Context-Sensitive Grammars (L → R, where
|L| ≤ |R|).
▶ Type 2: Context-Free Grammars (L → R, where L is a single
non-terminal).
▶ Type 3: Regular Grammars (L → aR or L → a, where L is a
single non-terminal and R is optional).
Chomsky Hierarchy

Figure: Chomsky Hierarchy


Visualizing Chomsky Hierarchy

▶ Nested structure showing:


▶ Type 3 inside Type 2.
▶ Type 2 inside Type 1.
▶ Type 1 inside Type 0.
▶ Highlight the inclusiveness of languages as the hierarchy
progresses.
Key Properties of Chomsky Hierarchy

▶ Type 0 (Unrestricted):
▶ Most powerful.
▶ No restrictions on production rules.
▶ Type 1 (Context-Sensitive):
▶ Useful for natural languages.
▶ Rules depend on the context of non-terminals.
▶ Type 2 (Context-Free):
▶ Widely used in programming languages.
▶ Parsable with efficient algorithms.
▶ Type 3 (Regular):
▶ Simplest and most restrictive.
▶ Can be represented by finite automata.
Why Study Formal Grammars?

▶ Foundation for understanding computation and automata.


▶ Basis for programming languages and compilers.
▶ Helps classify and analyze the complexity of languages.
Summary

▶ Formal grammars define the structure of languages.


▶ Chomsky Hierarchy classifies grammars into four types based
on production rules.
▶ Understanding the hierarchy helps analyze language
complexity and computational power.
Next Steps

▶ Upcoming Lecture: Regular Expressions and Languages.


▶ Recommended Reading:
▶ Ïntroduction to Automata Theory, Languages, and
Computationb̈y Hopcroft, Motwani, Ullman.
▶ Explore online resources for interactive grammar examples.
Questions and Discussion

▶ Open floor for queries and clarifications.


▶ Contact: [email protected] and 7987152575

You might also like