Normal Forms of CFG (CNF and GNF) | प्रसंग-मुक्त व्याकरण के सामान्य रूप (CNF और GNF)
Normal Forms of CFG (CNF and GNF) | प्रसंग-मुक्त व्याकरण के सामान्य रूप (CNF और GNF)
Context-Free Grammar (CFG) को व्यवस्थित रूप में प्रस्तुत करने के लिए इसे Normal Forms में रूपांतरित किया जाता है। यह रूप CFG को Parsing और Syntax Analysis के लिए उपयुक्त बनाते हैं। सबसे अधिक उपयोग किए जाने वाले Normal Forms हैं — Chomsky Normal Form (CNF) और Greibach Normal Form (GNF)।
परिचय / Introduction
CFG को Simplify और Standardize करने के लिए CNF और GNF का उपयोग किया जाता है। यह रूप Parsing Algorithms (जैसे CYK Algorithm) में उपयोगी होते हैं और Grammar की जटिलता को घटाते हैं।
1️⃣ Chomsky Normal Form (CNF) / चॉम्स्की सामान्य रूप
Chomsky Normal Form (CNF) में हर Production Rule निम्नलिखित दो रूपों में होता है:
A → BC
A → a
जहाँ:
- A, B, C Non-terminals हैं।
- ‘a’ Terminal symbol है।
CNF के नियम / CNF Rules
- ε-productions नहीं होने चाहिए (सिवाय Start Symbol के)।
- Unit Productions (A → B) नहीं होने चाहिए।
- हर RHS या तो दो Non-terminals या एक Terminal से बना हो।
उदाहरण / Example
Grammar:
S → ASA | aB
A → B | S
B → b
Step 1: Null Productions हटाएँ
S → ASA | AS | SA | aB | a
A → B | S
B → b
Step 2: Unit Productions हटाएँ
A → b | ASA | aB | a
Step 3: CNF में रूपांतरण
S → AB | a
A → BC | b
B → a
C → SB
2️⃣ CNF रूपांतरण की प्रक्रिया / Steps to Convert CFG into CNF
- Null (ε) productions हटाएँ।
- Unit productions हटाएँ।
- Useless symbols हटाएँ।
- हर rule को A → BC या A → a के रूप में बदलें।
उदाहरण:
S → AB | a
A → a
B → b
3️⃣ CNF के लाभ / Advantages of CNF
- Parsing आसान होता है।
- CYK Algorithm जैसे Parsing Algorithms के लिए आवश्यक।
- Grammar Validation सरल होती है।
4️⃣ Greibach Normal Form (GNF) / ग्रेबैक सामान्य रूप
Greibach Normal Form (GNF) में हर Production Rule इस प्रकार होता है:
A → aα
जहाँ:
- ‘a’ एक Terminal Symbol है।
- α शून्य या अधिक Non-terminals का अनुक्रम है।
GNF की विशेषताएँ / Properties of GNF
- हर Production एक Terminal Symbol से शुरू होता है।
- ε-productions नहीं होतीं।
- Top-Down Parsing के लिए उपयुक्त।
उदाहरण / Example
Grammar:
S → AB | b
A → aA | a
B → bB | ε
GNF में रूपांतरण के बाद:
S → b | aAB | ab
A → aA | a
B → bB | b
5️⃣ GNF रूपांतरण के चरण / Steps for Conversion to GNF
- Left recursion हटाएँ।
- CNF में Grammar परिवर्तित करें।
- हर Rule को Terminal Symbol से प्रारंभ करें।
6️⃣ CNF और GNF में अंतर / Difference Between CNF and GNF
| पहलू | CNF | GNF |
|---|---|---|
| Rule Structure | A → BC या A → a | A → aα |
| Parsing Type | Bottom-Up Parsing | Top-Down Parsing |
| Use | CYK Algorithm | LL Parser |
| ε-Productions | नहीं होतीं | नहीं होतीं |
| Initial Symbol | Terminal या दो Non-terminals | हमेशा Terminal |
7️⃣ Practical Uses / व्यावहारिक उपयोग
- Compiler Design में Syntax Checking।
- Parsing Algorithms (CYK, LL, LR) में।
- Formal Verification में।
🔟 निष्कर्ष / Conclusion
CNF और GNF दोनों Context-Free Grammar के Standard Forms हैं जो Parsing और Language Recognition को सरल बनाते हैं। जहाँ CNF Bottom-Up Parsing के लिए उपयुक्त है, वहीं GNF Top-Down Parsing के लिए प्रयोग किया जाता है। इन रूपों से Grammar को Standardized और Machine-readable बनाया जा सकता है।
Related Post
- Introduction to Automata Theory | ऑटोमाटा सिद्धांत का परिचय
- Review of Sets | सेट्स का पुनरावलोकन
- Mathematical Proofs (Induction and Contradiction) | गणितीय प्रमेय (आगमन और विरोधाभास द्वारा प्रमाण)
- Fundamentals of Languages, Grammars, and Automata | भाषाओं, व्याकरण और ऑटोमाटा के मूल सिद्धांत
- Alphabet and Representation of Language and Grammar | वर्णमाला और भाषा व व्याकरण का निरूपण
- Types of Automata and Their Applications | ऑटोमाटा के प्रकार और उनके उपयोग
- Finite Automata as Language Acceptor and Translator | भाषा स्वीकारक और अनुवादक के रूप में सीमित ऑटोमाटा
- Moore and Mealy Machines, Conversion and Composite Machine | मूर और मीली मशीनें, रूपांतरण और समग्र मशीनें
- Conversion Between Mealy and Moore Machines | मीली और मूर मशीनों के बीच रूपांतरण
- Composite Machine in Automata | ऑटोमाटा में समग्र मशीन
- Non-Deterministic Finite Automata (NDFA) | अनिश्चित सीमित ऑटोमाटा
- Deterministic Finite Automata (DFA) | निश्चित सीमित ऑटोमाटा
- Conversion of NDFA to DFA | एनडीएफए से डीएफए में रूपांतरण
- Minimization of Automata Machines | ऑटोमाटा मशीनों का लघुकरण
- Regular Expression in Automata | ऑटोमाटा में रेगुलर एक्सप्रेशन
- Applications of Regular Expressions | रेगुलर एक्सप्रेशंस के अनुप्रयोग
- Arden’s Theorem in Automata | ऑटोमाटा में आर्डन का प्रमेय
- Union, Intersection, Concatenation, and Closure in Automata | ऑटोमाटा में संयोजन, प्रतिच्छेद, संयोजन और क्लोज़र
- Two-Way Deterministic Finite Automata (2DFA) | द्विदिश निश्चित सीमित ऑटोमाटा
- Introduction and Types of Grammar in Automata Theory | ऑटोमाटा सिद्धांत में व्याकरण का परिचय और प्रकार
- Regular Grammar in Automata | ऑटोमाटा में रेगुलर व्याकरण
- Context-Free Grammar (CFG) in Automata | ऑटोमाटा में प्रसंग-मुक्त व्याकरण
- Context-Sensitive Grammar (CSG) in Automata | ऑटोमाटा में प्रसंग-संवेदनशील व्याकरण
- Derivation Trees and Ambiguity in Grammar | व्युत्पत्ति वृक्ष और व्याकरण में अस्पष्टता
- Simplification of Context-Free Grammar | प्रसंग-मुक्त व्याकरण का सरलीकरण
- Conversion Between Grammar and Automata | व्याकरण और ऑटोमाटा के बीच रूपांतरण
- Chomsky Hierarchy of Grammars | चॉम्स्की व्याकरण पदानुक्रम
- Chomsky Normal Form (CNF) and Greibach Normal Form (GNF) | चॉम्स्की एवं ग्रेबैक सामान्य रूप
- Introduction and Example of Pushdown Automata (PDA) | पुशडाउन ऑटोमाटा का परिचय और उदाहरण
- Deterministic and Non-Deterministic Pushdown Automata (DPDA vs NPDA) | नियतात्मक और अनियतात्मक पुशडाउन ऑटोमाटा
- Relationship Between PDA and Context-Free Grammar | PDA और प्रसंग-मुक्त व्याकरण का संबंध
- Parsing in Context-Free Grammar using PDA | PDA के माध्यम से पार्सिंग प्रक्रिया
- Ambiguity in Context-Free Grammar | प्रसंग-मुक्त व्याकरण में अस्पष्टता
- Normal Forms of CFG (CNF and GNF) | प्रसंग-मुक्त व्याकरण के सामान्य रूप (CNF और GNF)
- Conversion of CFG to NPDA | CFG से NPDA में रूपांतरण
- Conversion of NPDA to CFG | NPDA से CFG में रूपांतरण
- Petri Nets Model | पेट्री नेट्स मॉडल का परिचय
- Introduction to Turing Machine and its Components | ट्यूरिंग मशीन का परिचय और घटक
- Turing Machine as Language Acceptor | ट्यूरिंग मशीन के रूप में भाषा स्वीकारक
- Recognizing a Language using Turing Machine | ट्यूरिंग मशीन द्वारा भाषा की पहचान
- Universal Turing Machine (UTM) | सार्वभौमिक ट्यूरिंग मशीन (UTM)
- Linear Bounded Automata and Context Sensitive Languages | रैखिक सीमाबद्ध ऑटोमाटा और प्रसंग-संवेदनशील भाषाएँ
- Recursive and Recursively Enumerable Languages | पुनरावर्ती और पुनरावर्ती रूप से गणनीय भाषाएँ
- Unrestricted Grammars and Type-0 Languages | असीमित व्याकरण और टाइप-0 भाषाएँ
- Halting Problem and Post Correspondence Problem | हॉल्टिंग समस्या और पोस्ट पत्राचार समस्या
- Solvability and Unsolvability Concepts | हल करने योग्य और अ-हल करने योग्य समस्याएँ
- Church’s Thesis and Complexity Theory (P vs NP) | चर्च का सिद्धांत और जटिलता सिद्धांत (P बनाम NP समस्याएँ)