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

TOC

The document discusses various concepts in the theory of computation, including non-determinism, ambiguity in languages, and different forms of grammars such as Greibach and Chomsky Normal Forms. It also covers decidability, the characteristics of different automata, and the relationships between languages and grammars, including the concepts of inherently ambiguous languages. Additionally, it provides links to practice questions and resources for further study.

Uploaded by

Believer
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

TOC

The document discusses various concepts in the theory of computation, including non-determinism, ambiguity in languages, and different forms of grammars such as Greibach and Chomsky Normal Forms. It also covers decidability, the characteristics of different automata, and the relationships between languages and grammars, including the concepts of inherently ambiguous languages. Additionally, it provides links to practice questions and resources for further study.

Uploaded by

Believer
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 39

THEORY OF COMPUTATION

● Non-determinism of language (if it means, L is not DCFL) + ambiguity for all


possible grammars implies inherent ambiguity. Or if a language is
deterministic, it is surely not inherently ambiguous. But if a language is not
deterministic, it may or may not be inherently ambiguous.

● If a grammar is having both left and right recursion, then grammar may or
may not be ambiguous .

● For practising decidability and undecidability :


https://www.cs.rice.edu/~nakhleh/COMP481/final_review_sp06_sol.pdf
● Greibach Normal form is A → aB where B ∈ V*

No of steps to generate string of length n = n


● Chomsky Normal form is A → BC or A → a ( O(n3) time )

No of steps to generate string of length n = 2n-1


● Elimination of Epsilon productions : Whenever the start state is nullable
ie. accepts empty string, then the language contains epsilon and it must
be present in the start state production.
● Elimination of unit productions : This is unit production A → B ✅

This is not a unit production: A → a ❌

● Elimination of useless symbols : Production A → aA is useless


because there is no way to terminate it. If it never
terminates, then it can never produce a string. Hence this
production can never take part in any derivation.
● Set of all strings is countable and every language is countable while the
set of all languages is uncountable.
● Countable union Countable set is also countable.
● Subset of a countable set is either finite or countably infinite.
● Intersection of any two countable sets is either finite or countably
infinite.
● DFA can never go in an infinite loop. NFA, PDA, DPDA, LBA can go in an
infinite loop(repetitive computation loop). Infinite loops in these
machines can be detected. But turing machines loops always cant be
detected.
● For a particular given string, No of parse trees = No of LMD = No of
RMD.
● Parse tree vs Derivation (LMD, RMD, etc) : In a parse we can see what
productions are used but cannot see the order in which these
productions are applied. Whereas in case of Derivation, you can also
see the order in which the productions are applied.
● Every CFL except ϕ has at least one ambiguous grammar.
● A CFL is called unambiguous iff there exists an unambiguous grammar
G for L.
● A CFL L is called inherently ambiguous iff every CFG for L is ambiguous
● Regular grammar can be ambiguous but regular language can never be
ambiguous
● Every DCFL has at least one unambiguous grammar.
● 1. Each DCFL can be generated by a corresponding LR(k) grammar and each
LR(k) grammar generates one DCFL (one-to-one correspondence).
● 2. A language can be generated by more than one grammar, so for each
DCFL an unambiguous LR(k) grammar do exists ( means, no DCFL is
inherently ambiguous).
● 3. Each LR(k) grammar is unambiguous grammar, but each unambiguous
grammar need not be LR(k).
● 4. A language can only be inherently ambiguous while there is no such
concept of "inherently ambiguous grammar".
● 5. An inherently ambiguous language can only be nondeterministic while an
non-deterministic language may or may not be inherently ambiguous. For
example there are many CFLs which are not inherently ambiguous, while
there are such CFLs also which are inherently ambiguous.
● FA with a queue is equal to a Turing machine.
● FA with two stacks is equal to a Turing machine.
● TM with only 3 states == Standard TM
● Multitape TM with stay option and at most 2 states == standard TM
● If s1 and s2 are two countable sets then (S1 U S2) and (S1 x S2) is also
countable.
● The cartesian product of finite no of countable sets is countable.
● The Union of finite no of countable sets is countable.
● Power set of a countably infinite set is uncountable.
● Finite and countably infinite unions of countable sets are countable.
● Finite Cartesian products of countable sets are countable.
● A Cartesian product of countably infinitely many countable sets (with at
least two elements in each) is uncountable.
● Every regular grammar is linear but not every linear grammar is
regular.1
● https://gateoverflow.in/357504/gate-cse-2021-set-2-question-36 Must
read variations.
TEST SERIES GOOD QUESTIONS :
https://www.goclasses.in/s/courses/62ebac820cf2fa01164bb7a9/take
https://gateoverflow.in/376536/classes-test-series-2023-theory-computation-test-question
https://gateoverflow.in/376526/classes-test-series-2023-theory-computation-test-question
https://gateoverflow.in/377263/classes-test-series-2023-theory-computation-test-question
https://gateoverflow.in/377261/classes-test-series-2023-theory-computation-test-question
https://gateoverflow.in/377269/classes-test-series-2023-theory-computation-test-question
https://gateoverflow.in/377887/classes-test-series-2023-theory-computation-test-question
https://gateoverflow.in/377875/classes-test-series-2023-theory-computation-test-question
https://gateoverflow.in/377871/classes-test-series-2023-theory-computation-test-question
https://gateoverflow.in/379552/classes-test-series-2023-theory-computation-test-question
https://gateoverflow.in/379542/classes-test-series-2023-theory-computation-test-question
https://gateoverflow.in/379540/classes-test-series-2023-theory-computation-test-question
Good logic : GATE CSE 1994 | Question: 3.3 - GATE Overflow for GATE CSE

Was initially confused whether the language L={ } is considered as Regular language
or not !
Yes, the Language L= { } is considered as a Regular language.
GATE CSE 2016 Set 2 | Question: 42 - GATE Overflow for GATE CSE
Good question, took much time to solve :

GATE IT 2005 | Question: 39 - GATE Overflow for GATE CSE

Learned a new trick in this ques :


Simple trick solution :)

See what is Arden's method : GATE IT 2005 | Question: 37 - GATE Overflow for
GATE CSE

Good question : GATE IT 2007 | Question: 50 - GATE Overflow for GATE CSE
GATE IT 2007 | Question: 72 - GATE Overflow for GATE CSE
GATE IT 2008 | Question: 36 - GATE Overflow for GATE CSE

A Substring and a subset are different ! Substrings can not be obtained by


shuffling the positions of letters. Check this :
GATE CSE 2010 | Question: 39 - GATE Overflow for GATE CSE

GATE CSE 2014 Set 1 | Question: 36 - GATE Overflow for GATE CSE

G
ATE CSE 2021 Set 2 | Question: 47 - GATE Overflow for GATE CSE
Correct Option: B
Infinite set (because of ∗) of finite strings.

A string is defined as a FINITE sequence of characters and hence can never be infinite.

VERY GOOD QUESTION

GATE CSE 2006 | Question: 29 - GATE Overflow for GATE CSE

GATE CSE 2007 | Question: 31 - GATE Overflow for GATE CSE


GATE CSE 2014 Set 2 | Question: 15 - GATE Overflow for GATE CSE

GOOD QUESTION :

GATE CSE 2014 Set 2 | Question: 36 - GATE Overflow for GATE CSE

GOOD QUESTION :

GATE CSE 2018 | Question: 52 - GATE Overflow for GATE CSE

Observe here the difference between option A and option b :


Let L={a,b,ab,bbb}
Then option b gives:
{aa,bb,abba,bbbbbb} i.e., a string is concatenated with the reverse of the same
string..
Option a gives:
{aa,ab,aba,abb,ba,bb,bba,bbb,abb,abba,abbb,bba,bbba,bbbbb} i.e., a string is
concatenated with the reverse of any string in the language..
So, A is regular but B is Context free Language .

Good intuitive question :

GATE CSE 2020 | Question: 51 - GATE Overflow for GATE CSE

Please try to check their proofs from some good resources .


GATE IT 2006 | Question: 80 - GATE Overflow for GATE CSE

Very good question :


GATE IT 2006 | Question: 81 - GATE Overflow for GATE CSE

Did a mistake in NFA to DFA conversion.


Confused at some steps. Try to do it once. Clear all steps of NFA to DFA
conversion.
Forgot to merge the dead states of 2 DFA’s :
Isme mene a se start kr diya tha, didn't noticed ki only ’b’ bhi accept ho jayega
bana liya tha….
I made the DFA like this.

To be remembered :

Correct answer : C

GOOD QUESTION :

GA
TE CSE 1996 | Question: 2.9 - GATE Overflow for GATE CSE

GATE CSE 2000 | Question: 7 - GATE Overflow for GATE CSE

GOOD QUESTION :

GATE CSE 2003 | Question: 51 - GATE Overflow for GATE CSE


GOOD QUESTION

GATE IT 2007 | Question: 49 - GATE Overflow for GATE CSE

GATE CSE 2006 | Question: 33 - GATE Overflow for GATE CSE

GATE CSE 2008 | Question: 9 - GATE Overflow for GATE CSE


Com
plement of L2 is recursive as context-free complement is always recursive
(actually even context-sensitive).
GATE CSE 2013 | Question: 32 - GATE Overflow for GATE CSE

GATE CSE 2020 | Question: 10 - GATE Overflow for GATE CSE

L2 is tricky :
https://www.youtube.com/watch?v=zAzS1PzU0NQ
GATE CSE 2020 | Question: 32 - GATE Overflow for GATE CSE

Did a silly mistake in C. Jaldi jaldi me decision le liya :

GATE CSE 2021 Set 2 | Question: 12 - GATE Overflow for GATE CSE

GATE IT 2005 | Question: 4 - GATE Overflow for GATE CSE

See how to minimize a moore/mealy machine with the help of partition method.
https://www.youtube.com/watch?v=HzTePILLrsA
https://www.youtube.com/watch?v=7SYiI9ssdlA
GATE CSE 1996 | Question: 2.23 - GATE Overflow for GATE CSE
Nice logic :

GATE CSE 2006 | Question: 34 - GATE Overflow for GATE CSE

GOOD QUESTION :

GATE CSE 2010 | Question: 41 - GATE Overflow for GATE CSE

GATE CSE 2017 Set 1 | Question: 22 - GATE Overflow for GATE CSE
TOUGHHH QUESTION !!!

GATE CSE 2019 | Question: 48 - GATE Overflow for GATE CSE

Solved it in much more time than explained in solution : )

GATE CSE 2015 Set 2 | Question: 35 - GATE Overflow for GATE CSE

NEW CONCEPT :
Not able to make this logic :
ARDEN’s method :

Q2 state nhi banaya tha mene !


Missed it .

GATE CSE 2013 | Question: 17 - GATE Overflow for GATE CSE

GATE CSE 2019 | Question: 34 - GATE Overflow for GATE CSE

If it is written that "exactly after 100 steps" then it is decidable.


but after 100 steps we can not guarantee that it will halt or not.

GATE CSE 1990 | Question: 3-vii - GATE Overflow for GATE CSE
See what is partially decidable :

GATE CSE 2001 | Question: 2.7 - GATE Overflow for GATE CSE

REDUCIBILITY CONCEPT :

GATE CSE 2005 | Question: 45 - GATE Overflow for GATE CSE


GOOD QUESTION : https://gateoverflow.in/8562

A reducible to B :

A
B

.
.
GATE CSE 2012 | Question: 24 - GATE Overflow for GATE CSE

TOUGH QUESTION DIdn't understand !

GATE CSE 2017 Set 1 | Question: 39 - GATE Overflow for GATE CSE

"Given a <PDA> P and a NFA N, Deciding Whether they both accept the same language
or not" is Undecidable. "

"Given a <DPDA> D and a NFA N, Deciding Whether they both accept the same
language or not" is Decidable. "

Proof:

Let NFA is N and DPDA is D


we have to decide L(N) == L(D) ??
L(N) is regular hence DCFL and L(D) is already DCFL so it is Equality of DCFLs problem which is
Decidable

If it is NPDA ,It will be Equality of NCFLs which is Undecidable.

"Equality" and "Equivalence" are two different things. Equality of Grammars (Type 0-3
Grammars) is Decidable, But Equivalence is NOT Because Equivalence of Two
Grammars is a relation defined by "Equality of Their Corresponding Languages" , Which
is Undecidable for Type-0 Grammars.
GATE CSE 2018 | Question: 36 - GATE Overflow for GATE CSE

GATE CSE 2020 | Question: 26 - GATE Overflow for GATE CSE

S1 samajh nahi aaya :

GATE CSE 2021 Set 2 | Question: 36 - GATE Overflow for GATE CSE

GOOD QUESTION :
GATE CSE 2008 | Question: 51 - GATE Overflow for GATE CSE

For a language L is if we can form L using many grammar and each grammer must
be ambiguous then we said L is inherently ambiguous.
GATE IT 2004 | Question: 9 - GATE Overflow for GATE CSE

For any PDA which accepts by final state there is an equivalent PDA (equivalent
means that accepts the same language) which accepts by empty stack and vice-
versa.
Now, this is not the case for DPDAs.
The set of languages accepted by a DPDA by empty stack is a strict subset of the
set of languages accepted by a DPDA by final state.

Read more here:


GATE CSE 1999 | Question: 1.6 - GATE Overflow for GATE CSE
PUSH DOWN AUTOMATA QUESTIONS :
GATE CSE 2015 Set 1 | Question: 51 - GATE Overflow for GATE CSE
GATE CSE 2016 Set 1 | Question: 43 - GATE Overflow for GATE CSE
GATE CSE 2021 Set 1 | Question: 51 - GATE Overflow for GATE CSE
GATE IT 2004 | Question: 40 - GATE Overflow for GATE CSE
GATE IT 2005 | Question: 38 - GATE Overflow for GATE CSE

Didn’t understand this :

GATE CSE 2003 | Question: 15 - GATE Overflow for GATE CSE

GATE CSE 2016 Set 2 | Question: 44 - GATE Overflow for GATE CSE

TOUGH QUESTION !!
Kuch bhi samajh nhi aaya !!
GATE CSE 2004 | Question: 89 - GATE Overflow for GATE CSE
GATE CSE 2003 | Question: 54 - GATE Overflow for GATE CSE

GOOD QUESTION : GATE CSE 2003 | Question: 53 - GATE Overflow for GATE CSE
GATE CSE 2021 Set 1 | Question: 39 - GATE Overflow for GATE CSE

GATE CSE 2014 Set 2 | Question: 35 - GATE Overflow for GATE CSE
D option was tricky !!

POST CORRESPONDENCE PROBLEM:


Here starting symbol produces epsilon so it will also be there in the final result.

This is unit production A → B ✅


This is not a unit production: A → a ❌

Take care of edge cases like sigma star and epsilon,


Very good question !
Empty language means even epsilon can not be accepted.

You might also like