What if given grammar is ambiguous?

The Gateway to Computer Science Excellence

+30 votes

Which of the following are decidable?

- Whether the intersection of two regular languages is infinite
- Whether a given context-free language is regular
- Whether two push-down automata accept the same language
- Whether a given grammar is context-free

- I and II
- I and IV
- II and III
- II and IV

+33 votes

Best answer

Lets see options one by one :

- The language here will be regular as intersection of regular languages will lead to regular language only. And we know that given a regular language, whether it is finite or not is a decidable problem. This can be seen by observing the DFA -- if DFA contains a state which contains a loop and that state is reachable from the start state and that state is either a final state or leading to final state, then the language will be infinite.

- The regularity property is undecidable for context free languages. Hence, it is undecidable. Details regarding this : https://cs.stackexchange.com/questions/19482/why-is-deciding-regularity-of-a-context-free-language-undecidable

- Now equivalence of two CFLs is also an undecidable property. Hence, given $2$ PDAs which is nothing but characterizing CFLs, whether the $2$ CFLs will be same or not cannot be decided.

- Given a grammar, it is context free iff its productions are of the type $V \to ( V \cup \Sigma )^*$ which can be verified with a Turing machine. Hence, it is a decidable property..

**Hence, (B) should be correct answer.**

+20 votes

(1) Intersection of two regular languages is regular. And checking if a regular language is infinite is decidable.

(2) Undecidable

(3) Undecidable

(4) Decidable as we just have to check if the grammar obeys the rules of CFG. (Obviously undecidable had it been language instead of grammar)

Reference: http://gatecse.in/wiki/Grammar:_Decidable_and_Undecidable_Problems

(2) Undecidable

(3) Undecidable

(4) Decidable as we just have to check if the grammar obeys the rules of CFG. (Obviously undecidable had it been language instead of grammar)

Reference: http://gatecse.in/wiki/Grammar:_Decidable_and_Undecidable_Problems

0

How do we go about solving such questions ?

We need to learn the decidable and undecidable properties as such or is there any logic behind this ?

We need to learn the decidable and undecidable properties as such or is there any logic behind this ?

0

Why (2) is undecidable? if we simplify the CFG and compare the resulting grammar with chomsky form for RL then we can tell about it.

- All categories
- General Aptitude 1.9k
- Engineering Mathematics 7.5k
- Digital Logic 2.9k
- Programming and DS 4.9k
- Algorithms 4.4k
- Theory of Computation 6.2k
- Compiler Design 2.1k
- Databases 4.1k
- CO and Architecture 3.4k
- Computer Networks 4.2k
- Non GATE 1.4k
- Others 1.4k
- Admissions 595
- Exam Queries 573
- Tier 1 Placement Questions 23
- Job Queries 72
- Projects 18

50,737 questions

57,258 answers

198,087 comments

104,736 users