Toc 1
Toc 1
Countable:
Set of all recursively enumerable language over the alphabet {0, 1}
Set of all syntactically valid C-program
∑∗ is countable, where W = finite non-empty alphabet
Every enumerable set is countable
Every countable set is computable
Both recursive enumerable set and recursive set are countable
If ∑ is a finite set then ∑∗ is countable
The number of distinct Turing machines is countably infinite
The number of distinct push down machines is countably infinite
The number of distinct finite state machines is countably infinite
If A and B are countable set then (A U B) and (A * B) are countable
Un-countable:
Set of all languages over the alphabet {0, 1}
Set of all non – regular languages over the alphabet {0, 1}
∗
2∑ is uncountable, where W = finite non-empty alphabet
∗
If ∑ is a finite set then 2∑ is uncountable
The power set of an infinite set is not countable
If A is countable set then power set of A is also uncountable
Un-decidable:
Whether a given context free language (CFL) is regular
Membership problem for type-0 language
A Turing machine prints a specific letter
A Turing machine computes the product of 2 – numbers
Turing machine halts sometimes after K – steps on some / all inputs
Halting problem of Turing machine are undecidable
Ambiguity problem of context free grammar (CFG)
Deciding if a given CFG is ambiguous
Equivalence problem of CFG
Equivalence of two given Turing machine
Whether two push down automata (PDA) accept the same language
Does a given problem ever produce an output?
If L is a CFL then is 𝐿̅ also context free?
G is a CFG, is L(G) = ∑∗ ?
M is a Turing machine, Is L(M) regular?
Given a Turing machine ‘M’, is L(M) = ø?
Given CFG’s G1 and G2, is L(G1) = L(G2)?
Given a Turing machine ‘M’ and a string W, is WL(M)?
Given a CFG G, is L(G) = ∑∗ for some alphabet ∑ ?
Given two Turing machine ‘M1’ and ‘M2’, decide if L(M1) = L(M2)
Given a Turing machine ‘M’, decide if L(M) is regular
Given a Turing machine ‘M’, decide if M accepts all strings
Are 2 – CFG equivalent?
Is the language accepted by a Turing machine empty/finite/regular/context – free?
Does a Turing machine meet it’s ‘specification’, that is does it have any ‘bugs’
Does L(M) contain a string of length K, for some given K 1?
Post correspondence problem (PCP) is undecidable
Modified Post correspondence problem (MPCP) is undecidable
If L1 ≤ L2 and L1 is undecidable then L2 is undecidable
Does L(M) contain any 2-strings of the same length?
Is the language L(M) finite?
Do two Turing machine ‘M1’ and ‘M2’ accept the same language i.e, L(M1) = L(M2)
Does a given Turing machine M halt on all input?
Does a Turing machine M halt for any input i.e, L(M) = ø?
[THEORY OF COMPUTATION] GATE 2024
Does a Turing machine M halt when given a blank input tape?
Empty word halting problem is undecidable
State entry problem of Turing machine is undecidable
Halting problem of Turing machine is undecidable
For an unrestricted grammar G and a string W, whether WL(G)
Given a Turing machine ‘M’, whether L(M) is regular
Given two grammars G1 and G2, whether L(G1) = L(G2)
L = {<M> | L(M) = ø}------------[<M> = Encoding of Turing machine M]
L = {<M> | L(M) is not recursive}
L = {<M> | L(M) contain at least 21 members}
L = {<M> | M is a Turing machine that accepts a string of length 2014} ---Recursively enumerable language
L = {<M> | M is a push down automata (PDA) such that L(M) = ∑∗ }
Rice’s theorem: Every non – trivial property of the recursively enumerable language is undecidable (L is
non – trivial if both the sets L and L’ are non – empty) or Every (non – trivial) question asked about
recursively enumerable language is undecidable
Decidable:
Given a regular expression R and a string W, is WL(R)?
Given a CFG G, L(G) = ø?
Given NFA’s N1 and N2, is L(N1) ∩ L(N2) = ø?
Given a CFG G = (N, ∑ , P, S) and a string W∑∗ , does WL(G)?
Membership problem for CFG is decidable
If a given string is generated by a given CFG
If the language generated by a given CFG is empty/finite
A is a DFA and N is an NFA, is L(A) = L(N)?
If L is a regular language (RL), then is 𝐿̅ also regular?
If L is a recursive language, then is 𝐿̅ also recursive?
Whether the intersection of two regular languages is infinite
Whether a given grammar is context free
Fitness problem for finite state automata(FSA)/ also CFG
Equivalence problem for finite state automata(FSA)
Given a Turing machine ‘M’, a string ‘S’ and an integer ‘K’, ‘M’ accepts ‘S’ within K-steps
Language accepted by a given finite machine is not empty
Language generated by a CFG is non-empty
An arbitrary Turing machine halts after 100 steps
Turing machine halts immediately after K-steps on some/all inputs
Membership problem in CFL
Whether a FSA halts on all inputs
Given a Turing machine ‘M’, decide if M takes more than 1073 steps on every string
Given an NFA ‘N’, whether there is a deterministic PDA ‘P’ such that N and P accept the same language
The complement of every Turing decidable language is Turing decidable
If L is a language in NP, then L is Turing decidable
If L1 ≤ L2 and L2 is decidable then L1 is also decidable
Recursive language are decidable
Recursive enumerable language are semi-decidable
Recursive language are Turing decidable
Every decidable language is enumerable
Post correspondence problem (PCP) and Modified Post correspondence problem (MPCP) over one symbol
(unary alphabet) is decidable problem
A problem whose language is recursive is called as decidable
Does a given finite state machine (FSM) accept a given string?
Does a given CFG generate an infinite number of strings
Set of all CFL’s
Set of all finite languages
Set of all regular languages
Whether a given Turing machine will print some non-blank character?
Whether a given Turing machine will ever make a left move?
[THEORY OF COMPUTATION] GATE 2024
Will a Turing machine hang within K (finite) steps?
Will a string W be accepted by Turing machine after K (finite) steps?
State of Turing machine after K (finite) steps?
A problem whose language is recursion is called as decidable
L = {<M> | M takes more than 2021 steps on all/some inputs}
L = {<M, W, q> | M on input W reaches state ‘q’ in exactly 100 steps}
L = {<M> | M is a DFA such that L(M) = ø}
L = {<M> | M is a DFA such that L(M) = ∑∗ }
L = {<M> | M is a PDA such that L(M) = ø}
L = {<D1, D2> | D1, D2 are DFA with L(D1) = L(D2)}
L = {<D, W> | D is a DFA that accepts string W}
L = {<N, W> | N is a NFA that accepts string W}
L = {<R, W> | R is a regular expression that generates string W}
L = {<D> | D is a DFA with L(D) = ø}
L = {<G, W> | G is a CFG that generates string W}
L = {<G> | G is a CFG with L(G) = ø}
L = {<M, q> | M is a Turing machine(TM) that visits state q on some input within 100 steps}
L = {<D> | L(D) is an infinite language, D is a DFA}
L = {<M> | M is a TM and L(M) is countable} = set of all Turing machines
L = {<M> | M is a TM and L(M) is uncountable} = { }
L = {<M> | M is a TM, Mh is a TM that halts on all inputs and ML(Mh)}
L = {<M, W> | M is a TM, W is a string, and there exist a TM, M’ such that W∉ L(M)∩L(M’)}
L = {<M> | M is a TM and there exists an input on which M halts within 100 steps}
L = {<M> | M is a TM and M is the only TM that accepts L(M)} = { } = empty set
L = {<M> | M is a TM and |M|<100}
L = {<M> | M is a TM that halts on all inputs and L(M) = L’ for some undecidable language L’} = { }
L = {<M, W, K> | M is a TM and M does not halt on W within K-steps, K is a constant}
L = {<M>|∃x, y∑∗ such that either xL(M) or y∉L(M)}
L = {<M>|there exist TM M’ such that <M> ≠ <M’> and L(M) = L(M’)} = Language of all TM’s
L = {<M, W> | W is a prefix of <M>}
L = {<M> |there exists two TM’s M1 and M2 such that L(M) ⊆ L(M1) U L(M2)} = Language of all TM’s
L = {<M, W> | M is a TM that accepts W using atmost 2|W| cells of its tape}
Recursive function:
A function which calls itself directly or indirectly and terminates after finite number of steps is known as recursive
function
P and NP problem:
NP complete problems are hardest problems in NP
If NP complete is in P then P = NP
P problems are tractable
Whether P = NP is undecidable problem
Every P problem is in NP
Every NPC problem is in NP
Every NPC problem is in NPH
NPC = NP ∩ NPH
If L1 NPC and L1 P then N = NP
NP complete ⊆ NP and NP complete ⊆ NP hard
P ⊆ NP ⊆ Recursive
If L1, L2 NP, L1 ≤ L2, and L1 is NP complete then L2 is NP complete
If L1, L2 NP, L1 ≤ L2, and L2 is NP complete then L1 need not be NP complete but NP
NOTE:
Algebraic numbers (root of polynomials with algebraic coefficients) are Turing computable
Transcendental mathematical constant (e, 𝜋, etc.) are Turing computable
Addition, Multiplication, Subtraction, Exponential, Factorial etc. are Turing computable
All uncomputable function are not Turing computable
The maximum no. of 1’s left on the tape after TM halts is uncomputable
The maximum no. of moves than can made by TM is uncomputable
Recursive languages are enumerable in lexicographical order by TM
Every recursive language is recursively enumerable
A language is REL iff it is Turing enumerable
All REL are not recursive
Primitive recursive function ⊆ Total recursive function ⊆ Partial recursive function
Non REL’s can be proved using diagonalization, complementation of REL, reduction from some non – REL,
or rice theorem with non-trivial property
Non deterministic TM(NTM) ≡ Deterministic TM(DTM)
Recursive languages is Turing decidable
REL is Turing recognizable
THEORY OF COMPUTATION GATE 2024
Regular Expression: It is a mathematical/logical representation of a regular language
Operators of Regular Expression:
Kleene clouser ( * )
Concatenation ( . )
Union ( + )
Properties of Regular Expression:
If R1, R2 and R3 are regular expression
Commutative Rule:
R1 + R 2 = R 2 + R 1
R1 . R2 ≠ R2 . R 1
Associative Rule:
R1 + (R2 + R3) = (R1 + R2) + R3
R1 . (R2 . R3) = (R1 . R2) . R3
Identity Rule:
R . = . R = R [ = identity element w.r.t concatenation ( = 1)]
∅ + R = R + ∅ = R [∅ = identity element w.r.t union (∅ = 0)]
R.∅=∅.R= ∅
Union operator satisfies commutative property and associative property
The concatenation operator satisfies associative property but not commutative property
Both left and right distributive properties of concatenation over union are satisfied
R(S + T) = RS + RT
(S + T)R = SR + TR
Both left and right distributive property of union over concatenation are not satisfied
ST + R ≠ (S + R)(T + R)
R + ST ≠ (R + S)(R + T)
Union operator satisfies idempotent property but the concatenation operator does not satisfy
R+R=R
R.R ≠ R
If R1 and R2 are regular expression; then R1 + R2 is also regular expression
If R1 and R2 are regular expression; then R1 . R2 is also regular expression
If R is regular expression; then (R) is regular expression
If R is regular expression; then R* is regular expression
Pumping Lemma:
Pumping lemma can be used to prove that a given language is non – regular (using proof by contradiction).
3. L = {∑∗ = w = (a + b)* = {a, b}*} = language accept all value over ∑ = {a, b} = {, a, b, ab, ba, aa, bb,…}
L = {W | W {a, b}*}
L = {an | n 0}
L = {wxwy | x, y {a, b}*, w {a, b}*}
L = {xwyw | x, y {a, b}*, w {a, b}*}
14. L = { awa | w {a, b}*} = every string start with a and end with a
15. L = { awb | w {a, b}*} = every string start with a and end with b
16. L = every string start and end with same symbol = {, a, b, aa, bb, aba, bab, ….}
THEORY OF COMPUTATION GATE 2024
17. L = every string start and end with different symbol = {ba, ab,………….}
18. L = { abwba | w {a, b}*} = every string start with ab and end with ba
19. L = every string start with ab and end with ab (Excluding the string)
50. L = { w | w {0, 1}*} = {, 0, 1, 00, 11, 01, 10, …} = language accept all binary strings
56. L = { set of all string over {0, 1} if it start with 0 then having odd length and if it start with 1 then having even
length}
58. L = { an | n 1}
59. L = { an | n 0 & n ≠ 1}
60. L = { an | n 0 & n ≠ 2}
61. L = { an | n 0 & n ≠ 3}
THEORY OF COMPUTATION GATE 2024
62. L = { an | n 0 & n ≠ 1, 3}
65. L = { anbm | n 1, m 0} = any no. of a followed by any no. of b where each string contain at least 1-a
67. L = { amb | m 0}
68. L = { ambn | m = 2, n = 1 }
THEORY OF COMPUTATION GATE 2024
69. L = { ambn | m ≤ n < 2 }
Complement of DFA:
If L is a regular language then complement of L is 𝐿̅ = ∑∗ - L
To get complement of DFA, make all final state as a non – final and all non – final state as
final without changing transition.
Every string contain 000 as a sub-string vs each string not contain 000
Length of string is even vs length of string is odd
Even no. of a’s vs Odd no. of a’s
Transition function: The transition function defines the movement of an automata from one state to another
by treating the current state and current input symbol as an ordered pair. For each pair of ‘current state’ and
‘current input symbol’ the transition function produces as output the next state in the automata.
Transition function:
T (Q0, 1) Q0
T (Q0, 0) Q1
T (Q1, 0) Q2
T (Q2, 1) Q1
T (Q1, 1) Q1
Input
symbol
THEORY OF COMPUTATION GATE 2024
Product automata:
Work between two statements (statement 1 and statement 2)
Calculate no. of state and final state in that two statements
In product automata, total state = product of number of two statement
In product automata, for AND operation, final state of product automata is merged state of both statement
final state [AND = Common] and for OR operation, final state of product automata is any one final state of
any statement present [OR = all].
THEORY OF COMPUTATION GATE 2024
Minimization of DFA(Partition algorithm):
THEORY OF COMPUTATION GATE 2024
Non - deterministic Finite Automata (NFA):
A FSM is called as NFA iff either one of these condition holds ----
2. L = {0W0 or 1W1 | W {0, 1}*} = { set of all strings over {0, 1} that start and end with same symbol}
3. L = {W100W2 | W1 & W2 {0, 1}*} = { set of all strings over {0, 1} containing 00 as a substring}
5. L = {anbm | n, m 0}
THEORY OF COMPUTATION GATE 2024
NFA to DFA conversion: if NFA final state present in any DFA state, then that DFA state will be a final state
and In DFA, = initial state is final state
Reversal of DFA:
1. Make initial state as a final and all final state as initial
2. Change direction of arrow
3. Most of the time the reversal of DFA will derive NFA
4. If there is more than one final state in DFA; then it’s reversal machine will always be NFA
Example:
THEORY OF COMPUTATION GATE 2024
If n – is the no of states in NFA; then the maximum no of states in corresponding DFA will be 2 n
So, [n(NFA) ≤ 2n(DFA)]
THEORY OF COMPUTATION GATE 2024
Grammar:
It is a set of rules (Production)
It represents a languages
L(G) : Language generated by G
Regular grammar:
It’s represent a regular language
It is either LLG (Left linear grammar) or RLG (Right linear grammar)
LLG (Left linear RLG (Right linear LG (Linear CFG (Context free
grammar) grammar) grammar) grammar)
VLHS -> VRHST* | T* VLHS -> T*VRHS | T* VLHS -> T*VRHST* | T* VLHS -> Anything
VLHS -> (VRHS + T)*
1. S -> Aab | Ac 1. S -> aS | abA 1. S -> aA | 1. S -> AB
A -> Sa | | abc A -> A -> Bb A -> a
2. S -> Sab | Sa | 2. S -> aA B -> aSb B -> b
A -> bB 2. S -> aaSb | 2. Every LLG
B -> aS | d 3. Every RLG
4. Every LG
Ex:
S -> SS
S -> a
S -> b Right most derivation (RMD) Left most derivation (LMD)
o String (W) = abba
Since two different parse trees exist for string w, therefore the given grammar is ambiguous.
THEORY OF COMPUTATION GATE 2024
THEORY OF COMPUTATION GATE 2024
Even length palindrome:
S -> a S a | b S b |
L = {wwR | w {a, b}* }
L = {set of all even length palindromes over ∑ = {a, b}}
L = {x | x (a, b)*, x = xR , | x | = even}
All palindrome:
S -> a S a | b S b | a | b |
L = {0i1j | i = 2j + 1 } L = {an! | n 0}
L = {0i1j | i ≠ 2j}
L = {aibjck | i ≤ j ≤ k}
L = {0P1Q0R | P, Q, R ≥ 0, P ≠ R} [not regular]
L = {ww | w (a + b)*}
L = {0P1Q0R | P, Q, R ≥ 0} = 0*1*0* [regular]
L = {0i1j | j = i2}
L = {0P1Q0R | P, Q, R N & P = Q = R}
L = {0i1j0k | j = max(i, k)}
L = {0P1Q | P, Q N & P = Q}
L = {wwRw | w (a + b)*}
L = {0P1Q | P, Q N}
L = {ambm C anbn | m, n ≥ 0} L = {ww | w (a + b)*} [ but its complement
L = {0n+m1n0m | n, m ≥ 0} is CFL]
L = {0n+m1n+m0m | n, m ≥ 0}
L = {wwR | w {0, 1}* } [Even palindrome]
L = {0n+m1n+m0n+m | n, m ≥ 0}
L = {wwR | w {a, b}* } [Even palindrome]
L = {wanwRbn | w {a, b}*, n 0 }
L = {wanbnwR | w {a, b}*, n 0 }
L = {ambncpdq | m = n = p & p ≠ q, where m, n,
L = {anwan | w {a, b}* } [regular]
p, q 0}
L = {wxwR | w,x {a, b}*, |w|, |x| > 0}
L = {ambncpdq | mn = p + q, where m, n, p, q
[regular]
0}
L = {wxxRwR | w,x {a, b}*}
L = {anbnc2n | n 0} [recursive]
L = {wwRxxR | w,x {a, b}*}
L = {anbnc2n | n 1}
L = { xy | x, y (a + b)*, |x| = |y|, x ≠ y}
L = {ambnambn | m, n 1}
L = {anbi | i {n, 3n, 5n}, n ≥ 0}
THEORY OF COMPUTATION GATE 2024
DCFL’s: CSL’s:
L = {anbn | n ≥ 0} [DCFL but not regular] L = 𝑎𝑛
2
NOTE:
Intersection of 2 Regular Language is regular
Intersection of 2 Recursive Language is recursive
Intersection of 2 REL is RE
The C language is CSL
Union of two CFL is context free
If L1 = RL, L2 = CFL, L3 = Recursive language & L4 = REL then
(L1’ U L2’)’ is CFL
L1 U (L2 U L2’) is CFL
(L1 ∩ L2) U (L1’ ∩ L2) is CFL
(L1 ∩ L2) is CFL
(L2 ∩ L1) is CFL
(L1 . L2) is CFL
(L1 U L2 ) is CFL
L3’ U L4 is REL
L2’ U L4 is REL
L2’ U L3 is recursive
L1* U L2 is CFL
L2’ is recursive
L1’ is regular
(L2 - L1) is CFL
THEORY OF COMPUTATION GATE 2024
REL
CSL
CFL
RL
1. FA (DFA = NFA) < DPDA < PDA < LBA < TM (DTM = NDTM)
2. Type 3 ⊆ Type 2 ⊆ Type 1 ⊆ Type 0
3. Regular languages ⊆ CFL’s ⊆ CSL’s ⊆ REL’s
4. DCFL’s ⊂ CFL’s
5. If NFA has n-states then the equivalent DFA has at most 2n states
6. FA ≅ TM with read only tape ≅ TM with unidirectional tape ≅ TM with finite tape ≅ PDA with finite stack
7. PDA ≅ FA with stack
8. TM ≅ PDA with additional stack ≅ FA with two stack
9. Mealy & Moore machines have same power
10. Recursive enumerable language is Turing recognizable
11. Recursive language is Turing decidable