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

CT-2 QB[1]

The document covers various topics in formal languages and automata theory, including converting grammars to Greibach Normal Form (GNF), proving ambiguity in grammars, simplification of context-free grammars (CFG), constructing pushdown automata (PDA), and understanding acceptance mechanisms. It also discusses DFA minimization algorithms, Chomsky language classification, and provides specific examples and exercises related to these concepts. Additionally, it includes tasks for converting PDAs to CFGs and deriving parse trees for given strings.

Uploaded by

ak2600
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)
8 views

CT-2 QB[1]

The document covers various topics in formal languages and automata theory, including converting grammars to Greibach Normal Form (GNF), proving ambiguity in grammars, simplification of context-free grammars (CFG), constructing pushdown automata (PDA), and understanding acceptance mechanisms. It also discusses DFA minimization algorithms, Chomsky language classification, and provides specific examples and exercises related to these concepts. Additionally, it includes tasks for converting PDAs to CFGs and deriving parse trees for given strings.

Uploaded by

ak2600
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/ 14

1. Convert the following grammar to GNF.

i. S🡪XA | BB,
B🡪b | SB,
X🡪b,
A🡪a.
ii. S 🡪 AB
A 🡪BS | b
B 🡪 SA | a
iii. S → ABA
A→aA | ε
B →bB| ε
2. Prove that S🡪aS | aSbS | ε is ambiguous. Find the LMD and RMD for
the string w=aab and the corresponding parse tree.
3. Explain about Simplification of CFG and simplify the given
grammars
i) S🡪aS | AB, A🡪 ε,B🡪 ε, D🡪b.
ii)S->ABC,A->BC|a,B->bAC| ε.
iii) S🡪Aa|B,B🡪A|bb,A🡪a|bc|B
iv)S→aAa|aB, A→aS|bD, B→aBa|b,C→ abb | DD,
D→aDA

4. Construct a PDA for the following languages


i. L=anbncmdm where n,m>=1.
ii. L = {wwR | w ε(0+1)* } and process the input 010010.
iv. L={anb2n|n>=1}
v. L= {anbmcn | m,n >=1} by empty stack.

5. Convert the following CFG to PDA.


i. E->I|E+E|E*E|(E)
I->a|Ia|0|I0
ii. S 🡪 aA
A 🡪 aABC | bB |a
B🡪b
C🡪c
Check whether the string abcba is accepted

6. What is an instantaneous description of a PDA? How will you


represent it? Also give the three important principles of ID and their
transaction.
Instantaneous Description of a PDA
An instantaneous description (ID) of a Pushdown Automaton (PDA) is a snapshot of
the current state of the PDA at any point in its computation. It represents:
- The current state of the PDA.
- The remaining input string.
- The contents of the stack.

Representation
An ID can be represented in the format: (q,w,𝛂)where:
- q = current state of the PDA.
- w = remaining input string (input not yet processed).
- 𝛂 = contents of the stack (top of the stack is on the left).

Principles of ID
1. Initial State:
- The ID starts from an initial configuration, representing the beginning of
computation with the initial state, full input string, and an initial stack configuration.
2. Transitions:
- The PDA transitions from one ID to another based on input symbols, the current
stack top, and the defined transition function. A transition can modify the state,
consume input, and change stack contents.
3. Final State:
- An ID represents acceptance when it reaches a configuration with an empty input
string and either an empty stack or a specified final stack condition, depending on the
PDA design.

7. Explain the DFA Minimization algorithm and minimize the finite


automaton following the table filling method.
DFA Minimization Algorithm
The DFA (Deterministic Finite Automaton) minimization algorithm is used to reduce
the number of states in a DFA while preserving its language.
The goal is to find the smallest equivalent DFA.
Step 1:
Remove Unreachable States
- Identify Reachable States: Start from the initial state and mark all states that
can be reached by any input string.
- Eliminate Unreachable States: Remove any states that are not marked as
reachable.
Step 2:
Partitioning States
- Initial Partition: Create two groups:
One for accepting states.
One for non-accepting states.
- Refinement: Iteratively refine these groups until no further splitting is
possible:
For each group, check if any two states can be distinguished based on their
transitions. If they lead to different groups for some input symbol, split the
group.
Repeat this process until all groups are stable (no further splits occur).
Step 3:
Construct the Minimized DFA
- New States: Each group in the final partition becomes a single state in the
minimized DFA.
- Transitions: Define transitions based on the original DFA:
For each state in the minimized DFA, define transitions to the new states
according to the input symbols, using the original DFA's transition function.
- Initial and Accepting States: Determine the initial state (the group containing
the original initial state) and the accepting states (the groups containing
accepting states).

The DFA minimization algorithm effectively reduces the complexity of the automaton
while maintaining its language, improving efficiency in processing and memory
usage.

8. Convert the following PDA to CFG.

9. Convert the following into Chomsky's Normal Form


i. S 🡪 aAa | bBb | ε
A🡪C|a
B 🡪C | b
C 🡪 CDE | ε
D 🡪 A | B |ab
ii. S→cCD|dTC|ε
T→cDC|cST|a
C→aTD|c
D→dC|d
iii. S→0A0|1B1|BB
A→C
B→S|A
C→ S | €
10. Explain acceptance by final state and acceptance by empty stack of
pushdown automata.
Pushdown Automata (PDAs) are a type of automaton that extend finite automata with
a stack, allowing them to recognize a broader class of languages, specifically
context-free languages. PDAs can accept strings in two different ways:
- acceptance by final state
- acceptance by empty stack.

1. Acceptance by Final State


Definition:
A PDA accepts an input string by final state if, after processing the entire
string, the PDA reaches one of its designated accepting states.
Process:
○ The PDA starts in the initial state with the input string and an initial stack
configuration.
○ It processes the input symbol by symbol, making transitions based on its
current state, the current input symbol, and the top symbol of the stack.
○ If the PDA finishes reading the input string and reaches a designated accepting
state, the input is considered accepted, regardless of the content of the stack.
Characteristics:
○ Useful when the structure of the input string alone determines acceptance.
○ Allows for the stack to retain information that may not directly influence the
acceptance.

2. Acceptance by Empty Stack


Definition:
A PDA accepts an input string by empty stack if, after processing the entire
string, the stack is empty, regardless of the current state.
Process:
★ The PDA begins with the input string and an initial stack configuration.
★ As it processes the string, it manipulates the stack according to its transition
rules.
★ If, after reading the entire input string, the stack is empty, the input is
accepted, irrespective of the state the PDA is in at that point.
Characteristics:
★ Focuses on the stack’s contents as a means of acceptance, which can be useful
for languages where the balance of symbols is critical (like matching
parentheses).
★ It allows more flexibility in the states since acceptance depends solely on stack
emptiness.

11. Give the leftmost and rightmost derivation for the string ‘aabbbbaa’
using the grammar S 🡪aB | bA, A 🡪a | aS | bAA, B 🡪 b | bS | aBB.
12. Explain in detail about Chomsky language classification.

Chomsky Language Classification


The Chomsky hierarchy classifies formal languages into four types based on their generative
power and the complexity of their grammars.
Hierarchy Levels:
The hierarchy consists of four types:
- Type 0 (recursively enumerable)
- Type 1 (context-sensitive)
- Type 2 (context-free)
- Type 3 (regular).
Type 0 - Recursively Enumerable Languages:
❖ Defined by unrestricted grammars.
❖ Can be recognized by a Turing machine.
❖ No restrictions on production rules.
❖ Languages are not necessarily decidable.
Type 1 - Context-Sensitive Languages:
❖ Defined by context-sensitive grammars.
❖ Can be recognized by a linear-bounded automaton (a restricted Turing machine).
❖ Production rules can have context but must maintain length (i.e., the left-hand side
must be less than or equal to the right-hand side).
Type 2 - Context-Free Languages:
❖ Defined by context-free grammars (CFGs).
❖ Can be recognized by a pushdown automaton (PDA).
❖ Production rules have a single non-terminal on the left side.
❖ Used in programming languages and parsing.
Type 3 - Regular Languages:
❖ Defined by regular grammars.
❖ Can be recognized by finite automata (DFA or NFA).
❖ Production rules are limited to single non-terminals producing a terminal or a
terminal followed by a non-terminal.
❖ Easily represented by regular expressions.
Inclusion Relationships:
Type 3 ⊆ Type 2 ⊆ Type 1 ⊆ Type 0.
Each type of language is a subset of the more powerful types.
Closure Properties:
Regular languages are closed under union, intersection, and complementation.
Context-free languages are closed under union and concatenation but not under
intersection or complementation.
Grammars:
Type 0: Unrestricted grammar with no restrictions.
Type 1: Context-sensitive grammar where production rules depend on context.
Type 2: Context-free grammar focused on single non-terminals.
Type 3: Regular grammar with very limited production rules.
Automata Correspondence:
Each type of language has an associated automaton:
Type 0: Turing machine.
Type 1: Linear-bounded automaton.
Type 2: Pushdown automaton.
Type 3: Finite automaton.
Applications:
The classification is crucial in computer science, linguistics, and artificial intelligence,
affecting compiler design, language recognition, and more.
13. Construct a CFG for the language a)wwR b)ancmbn

14. Convert the following PDA to CFG.


δ(q0,0,Z0)=(q0,XZ0)
δ(q0,0,X)=(q0,XX)
δ(q0,1,X)=(q1,ε)
δ(q1,1,X)=(q1,ε)
δ(q1,ε,X)=(q1,ε)
δ(q1,ε,Z0)=(q1, ε)

15. For the grammar G defined by the Production.


S->A|B
A->0A| ε
B->0B|1B|ε
Find the parse tree for yields i)1001, ii)00101.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

1.cNF GNF conversion


2.simplification of cfg
3.derivation.parse trees.ambiguity
4.pda construction
5.Minimization of DFA
6.properties of cfl and regular languages
7.pda to cfg conversion and cfg to pda

You might also like