
- Automata Theory - Applications
- Automata Terminology
- Basics of String in Automata
- Set Theory for Automata
- Finite Sets and Infinite Sets
- Algebraic Operations on Sets
- Relations Sets in Automata Theory
- Graph and Tree in Automata Theory
- Transition Table in Automata
- What is Queue Automata?
- Compound Finite Automata
- Complementation Process in DFA
- Closure Properties in Automata
- Concatenation Process in DFA
- Language and Grammars
- Language and Grammar
- Grammars in Theory of Computation
- Language Generated by a Grammar
- Chomsky Classification of Grammars
- Context-Sensitive Languages
- Finite Automata
- What is Finite Automata?
- Finite Automata Types
- Applications of Finite Automata
- Limitations of Finite Automata
- Two-way Deterministic Finite Automata
- Deterministic Finite Automaton (DFA)
- Non-deterministic Finite Automaton (NFA)
- NDFA to DFA Conversion
- Equivalence of NFA and DFA
- Dead State in Finite Automata
- Minimization of DFA
- Automata Moore Machine
- Automata Mealy Machine
- Moore vs Mealy Machines
- Moore to Mealy Machine
- Mealy to Moore Machine
- Myhill–Nerode Theorem
- Mealy Machine for 1’s Complement
- Finite Automata Exercises
- Complement of DFA
- Regular Expressions
- Regular Expression in Automata
- Regular Expression Identities
- Applications of Regular Expression
- Regular Expressions vs Regular Grammar
- Kleene Closure in Automata
- Arden’s Theorem in Automata
- Convert Regular Expression to Finite Automata
- Conversion of Regular Expression to DFA
- Equivalence of Two Finite Automata
- Equivalence of Two Regular Expressions
- Convert Regular Expression to Regular Grammar
- Convert Regular Grammar to Finite Automata
- Pumping Lemma in Theory of Computation
- Pumping Lemma for Regular Grammar
- Pumping Lemma for Regular Expression
- Pumping Lemma for Regular Languages
- Applications of Pumping Lemma
- Closure Properties of Regular Set
- Closure Properties of Regular Language
- Decision Problems for Regular Languages
- Decision Problems for Automata and Grammars
- Conversion of Epsilon-NFA to DFA
- Regular Sets in Theory of Computation
- Context-Free Grammars
- Context-Free Grammars (CFG)
- Derivation Tree
- Parse Tree
- Ambiguity in Context-Free Grammar
- CFG vs Regular Grammar
- Applications of Context-Free Grammar
- Left Recursion and Left Factoring
- Closure Properties of Context Free Languages
- Simplifying Context Free Grammars
- Removal of Useless Symbols in CFG
- Removal Unit Production in CFG
- Removal of Null Productions in CFG
- Linear Grammar
- Chomsky Normal Form (CNF)
- Greibach Normal Form (GNF)
- Pumping Lemma for Context-Free Grammars
- Decision Problems of CFG
- Pushdown Automata
- Pushdown Automata (PDA)
- Pushdown Automata Acceptance
- Deterministic Pushdown Automata
- Non-deterministic Pushdown Automata
- Construction of PDA from CFG
- CFG Equivalent to PDA Conversion
- Pushdown Automata Graphical Notation
- Pushdown Automata and Parsing
- Two-stack Pushdown Automata
- Turing Machines
- Basics of Turing Machine (TM)
- Representation of Turing Machine
- Examples of Turing Machine
- Turing Machine Accepted Languages
- Variations of Turing Machine
- Multi-tape Turing Machine
- Multi-head Turing Machine
- Multitrack Turing Machine
- Non-Deterministic Turing Machine
- Semi-Infinite Tape Turing Machine
- K-dimensional Turing Machine
- Enumerator Turing Machine
- Universal Turing Machine
- Restricted Turing Machine
- Convert Regular Expression to Turing Machine
- Two-stack PDA and Turing Machine
- Turing Machine as Integer Function
- Post–Turing Machine
- Turing Machine for Addition
- Turing Machine for Copying Data
- Turing Machine as Comparator
- Turing Machine for Multiplication
- Turing Machine for Subtraction
- Modifications to Standard Turing Machine
- Linear-Bounded Automata (LBA)
- Church's Thesis for Turing Machine
- Recursively Enumerable Language
- Computability & Undecidability
- Turing Language Decidability
- Undecidable Languages
- Turing Machine and Grammar
- Kuroda Normal Form
- Converting Grammar to Kuroda Normal Form
- Decidability
- Undecidability
- Reducibility
- Halting Problem
- Turing Machine Halting Problem
- Rice's Theorem in Theory of Computation
- Post’s Correspondence Problem (PCP)
- Types of Functions
- Recursive Functions
- Injective Functions
- Surjective Function
- Bijective Function
- Partial Recursive Function
- Total Recursive Function
- Primitive Recursive Function
- μ Recursive Function
- Ackermann’s Function
- Russell’s Paradox
- Gödel Numbering
- Recursive Enumerations
- Kleene's Theorem
- Kleene's Recursion Theorem
- Advanced Concepts
- Matrix Grammars
- Probabilistic Finite Automata
- Cellular Automata
- Reduction of CFG
- Reduction Theorem
- Regular expression to ∈-NFA
- Quotient Operation
- Parikh’s Theorem
- Ladner’s Theorem
Decision Problems of CFG
In this chapter, we will cover some interesting decision problems related to Context-Free Grammars (CFGs). We will see whether these problems are solvable in CFG or not. The answer will be Yes or No. In other words, they help us understand what kind of questions we can answer about CFGs using algorithms. Let us see the four main problems for a better understanding of the concept.
Problem 1: String Generation Problem
The problem states, imagine we have a CFG and a string. We want to check if the grammar can produce that exact string or not?
Solution
- First, we change the grammar into a special form called Chomsky Normal Form. This makes things easier to work with.
- Then, we check the string length. If the length is say n.
- We create all possible ways to generate strings using the grammar, but we only use 2n-1 steps. Because in Chomsky Normal Form, that's the maximum number of steps needed to create a string of length n.
- Finally, we check whether any of these ways produce our string. If yes, the answer will be positive.
This method always gives us an answer like yes or no, so we call it "decidable."
Problem 2: Emptiness Problem
The Problem states, consider we have a CFG, and we want to check if it can generate any strings at all? Or the string is empty of not
Solution
Here is a simple way to solve it out −
- We start by marking all the terminal symbols in the grammar. These are like the building blocks.
- Then, we look at each variable (non-terminal) in the grammar. If it can produce only marked symbols, we mark it too.
- We keep doing this until we can't mark any more variables.
- At the end, we check if the start symbol (the main variable) is marked. If it's not marked, the language is empty!
This method also always gives us a clear answer in yes or no, so it's decidable too.
Problem 3: Decidability of Context-Free Language?
The Problem states if we have a context-free language (CFL) and a string. We want to check whether the string belongs to that language or not?
Solution
We can always answer this question. In the following steps −
- We take the grammar that generates our CFL.
- We use the method from Problem 1 to check if this grammar can generate our string.
- If it can, the string is in the language. If not, it's not in the language.
This shows that every context-free language is decidable.
Problem 4: Equivalence of Context Free Grammar
The Problem states, if we have two CFGs and we want to know whether they generate the same language or not?
Solution
We can't always answer this question. So this problem can be said as "undecidable". There's no algorithm that can always tell us if two CFGs generate the same language.
This is because context-free languages have some limitations −
- They are not closed under intersection (when you combine two CFLs, you might not get a CFL).
- They are not closed under complementation (when you flip a CFL, you might not get a CFL).
These properties make it impossible to create a general method to compare two CFLs.
Conclusion
In automata theory, we use several classes of problems. The most interesting class of problems are decidable problems. It is nothing but checking whether that can be solvable or not.
In this chapter, we highlighted a set of decision problems corresponding to contextfree grammars. There are four problems that we covered here. Among them, three are decidable and the last equivalence is not decidable.