CFG and PDA Flashcards

1
Q

What does Lecture 12 aim to prove?

A

That context-free grammars and pushdown automata are equivalent in expressive power.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What does CFG ⇒ PDA mean?

A

For any context-free grammar, there exists a PDA that accepts the same language.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What does PDA ⇒ CFG mean?

A

For any PDA, there exists a CFG that generates the same language.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What does the PDA constructed from a CFG simulate?

A

Leftmost derivations of the grammar.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How many states does the PDA constructed from a CFG have?

A

Two states: one for setup, one for simulation.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What does the stack alphabet of a PDA from a CFG contain?

A

All terminals and non-terminals of the grammar: Σ ∪ V.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are the three types of transitions in the CFG ⇒ PDA construction?

A

(1) Push start symbol S, (2) Replace non-terminal X with production w, (3) Match and pop terminal symbols.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

When does the PDA accept in the CFG ⇒ PDA construction?

A

When input is fully read and the stack is empty.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Give a CFG that generates the language L = { ww^R | w ∈ {a

A

b}* }.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What transition does the PDA use to begin simulating a CFG?

A

(1, ε, ε) → (2, S) — pushes the start symbol S onto the stack.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What does DFA ⇒ CFG demonstrate?

A

That all regular languages are also context-free.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How is a CFG constructed from a DFA?

A

States become non-terminals; transitions become productions; accepting states allow ε-productions.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Give an example CFG for a DFA that accepts strings containing ‘baa’.

A

S → aS | bP, P → aQ | bP, Q → aR | bP, R → aR | bR | ε

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is the idea behind converting a PDA to a CFG?

A

Define grammar variables A_{pq} that describe stack-emptying paths from p to q.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Is the PDA ⇒ CFG construction examinable?

A

No — it’s covered conceptually but not tested.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What are context-free languages closed under?

A

Union, concatenation, and Kleene star.

17
Q

How do you construct a CFG for the union of two CFLs?

A

Use a new start symbol S and add rules S → S₁ | S₂, where S₁ and S₂ are the original start symbols.

18
Q

How do you construct a CFG for the concatenation of two CFLs?

A

Add a rule S → S₁ S₂, combining the start symbols of the two grammars.

19
Q

How do you construct a CFG for the Kleene star of a CFL?

A

Add rules S → ε and S → S S to allow repetition.

20
Q

What is a leftmost derivation?

A

A derivation where the leftmost non-terminal is always the one replaced at each step.

21
Q

Why are leftmost derivations important?

A

They standardize derivations and are used in parsing and PDA simulations.