Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
5 views36 pages

Toc 1

The document outlines key concepts in the theory of computation, categorizing languages and problems into countable, uncountable, decidable, and undecidable sets. It provides examples of each category, including various problems related to Turing machines, context-free languages, and finite state machines. Additionally, it discusses the implications of reductions between problems and their decidability status.

Uploaded by

Soumen Golder
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)
5 views36 pages

Toc 1

The document outlines key concepts in the theory of computation, categorizing languages and problems into countable, uncountable, decidable, and undecidable sets. It provides examples of each category, including various problems related to Turing machines, context-free languages, and finite state machines. Additionally, it discusses the implications of reductions between problems and their decidability status.

Uploaded by

Soumen Golder
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/ 36

[THEORY OF COMPUTATION] GATE 2024

 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 WL(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 WL(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 WL(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 WL(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 ML(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 xL(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}

Undecidability / Decidability Table for Formal Languages


Problem [Decidable(√) & Undecidable(*)] Regular DCFL CFL Recursive REL
language language
1 Is WL? [Membership problem] √ √ √ √ *
2 Is L = ∅ ? [Emptiness problem] √ √ √ * *
3 Is L = Finite? [Fitness problem] √ √ √ * *
4 Is L1 = L2? [Equivalence problem] √ √ * * *
5 Is L1 ⊆ L2? [Subset problem] √ * * * *
6 Is L regular? [Regularity problem] √ √ * * *
7 Is L ambiguous? [Ambiguity problem] √ * * * *
8 Is L = ∑∗ ? [Universality/Totality problem] √ √ * * *
9 Is L1 ∩ L2 = ∅ ? [Disjoint/Intersection empty problem] √ * * * *
10 Is L = R? where, R is given regular language √ √ * * *
11 Is L1 ∩ L2 = L3? where L1, L2 and L3 are same type √ * * √ √
12 Is the complement of a language is also a language of the √ √ * √ *
same type?
13 Is 𝐿̅ finite? [Co-finiteness problem] √ * * *
14 State entry problem √ *
15 Halting problem of a Turing machine √ *
16 Empty word halting problem √ *
17 Uniform halting problem √ *
18 Blank tape halting problem √ *
[THEORY OF COMPUTATION] GATE 2024
 Reduction:
 P1 is Reducible to P2 (P1 ≤ P2): Problem P1 is Reducible to problem P2 means “the problem P2 is atleast as
hard as problem P1”
 P1 ≤m P2 : Problem P1 is many to one reducible to a problem P2
 P1 ≤P P2 : Problem P1 is polynomially reducible to a problem P2
 If P1 ≤ P2 and P1 is undecidable then P2 is also undecidable
 If P1 ≤ P2 and P2 is undecidable then P1 need not be undecidable
 If P1 ≤ P2 and P2 is decidable then P1 is also decidable
 If P1 ≤ P2 and P1 is decidable then P2 need not be decidable
 If P1 ≤ P2 and P2 is recursive then P1 is also recursive
 If P1 ≤ P2 and P1 is recursive then P2 need not be recursive
 If P1 ≤ P2 and P2 is recursive enumerable then P1 is also recursive enumerable
 If P1 ≤ P2 and P1 is recursive enumerable then P2 need not be recursive enumerable
 If P1 ≤ P2 and P2 is P-problem then P1 is also P-problem
 If P1 ≤ P2 and P1 is P-problem then P2 need not be P-problem
 If P1 ≤ P2 and P2 is NP-problem then P1 is also NP-problem
 If P1 ≤ P2 and P1 is NP-problem then P2 need not be NP-problem
 If P1 ≤ P2 and P2 ≤ P3 then P1 ≤ P3 (Transitivity)
 If P1 ≤ P2 and P2 ≤ P1 then P1 and P2 are polynomially equivalent
 If P1 ≤ P2 and P1 is not REL then P2 is also not REL
 If P1 ≤ P2 and P1 is not P-problem then P2 is also not P-problem
 If P1 ≤ P2 and P1 is not recursive problem then P2 is also not recursive problem

 Recursive function:
A function which calls itself directly or indirectly and terminates after finite number of steps is known as recursive
function

 Total Recursive function:


 Multiplication of two +ve integers is total recursive function or primitive recursive function
 Not all total recursive function are primitive recursive function
 Ackerman’s function is a total function
 All primitive recursive functions are total function
 Functions like n!, log 2 𝑛 etc. are total recursive functions
 Partial Recursive function:
 Subtraction of two +ve integers is partial recursive function
 The composition of partial (Total) functions yields a partial (Total) functions
 The minimization of a total recursive function is a partial recursive function
 Primitive recursive function ⊆ Total function ⊆ Partial recursive function
 Total recursive functions is decidable but partial recursive function is computable. Every
decidable function is computable but every computable function need not be decidable.

 Recursively Enumerable Language(REL):


 The class of languages recognized by the TM is known as REL
 A language generated by the unrestricted grammar is called as REL
 REL is Turing recognizable
 Closure properties of REL:
REL’s are closed under the REL’s are not closed under the
following properties---------------- following properties----------------
 Union operation
 Complement
 Intersection operation
 Set Difference / Difference
 Concatenation operation
 Symmetric difference
 Reversal operation
 XOR, NAND, NOR
 Kleene closure
 And any other operation which can be reduced to
 Positive closure
intersection and complement
THEORY OF COMPUTATION GATE 2024
 Recursive Language:
 If a language L is recursive, then it is REL
 Recursive languages are subset of REL
 Recursive languages are decidable but REL’s are partially decidable
 Closure properties of Recursive languages:
Recursive languages are closed  And any other operation which can
under the following properties-------- be reduced to intersection and
 Union operation complement
 Intersection operation  𝜀 – free homomorphism
 Concatenation operation
 Reversal(transpose) operation
 Kleene closure Recursive languages are not closed
 Positive closure under the following properties---------------
 Complement
 Set Difference / Difference  Homomorphism of a recursive
 Symmetric difference language
 XOR, NAND, NOR  Substitution of a recursive language

 Recursive languages are ----------------------------


 A proper superset of CFL
 Recognizable by Turing machine
 The complement of a recursive language is recursive
 If a language L and its complement 𝐿̅ are both recursively enumerable, then L must be recursive
 If L is recursive then 𝐿̅ is also recursive language
 If both L and 𝐿̅ are REL the both L and 𝐿̅ are recursive languages
 Complement of a CFL must be recursive
 Every context sensitive language L is recursive
 There exists a recursive language that is not context sensitive
 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 = {<M, W> | M is a TM that accepts W} is REL but not recursive
 L = {<M, W> | M is a TM that does not accepts W} is non REL
 L = {<M> | L(M) ≠ ø} is REL but not recursive
(0 + 1) ∗ 𝑖𝑓 𝑃 = 𝑁𝑃
 L={ so, L is recursive language
∅ 𝑜𝑡ℎ𝑒𝑟𝑤𝑖𝑠𝑒

 If L be a language and 𝐿̅ be its complement,  If L1 = regular language, L2 = DCFL and L3 =


then possible condition are --------- REL but not recursive language, then -------
 Both L and 𝐿̅ are recursive  (L1 ∩ L2) is DCFL
 Neither L nor 𝐿̅ is REL  (L1 U L2) is CFL
 One of L and 𝐿̅ is REL but not  (L1 ∩ L2 ∩ L3) is REL
recursive, the other is not REL  If L1 and L2 are REL, then -----------------
 If L1 = recursive language and L2 = REL but  (L1 U L2)
not recursive, then -----------------  (L1 * L2)
 (L2 – L1) is always REL  (L1 ∩ L2)
 (L2 U L1) is always REL  𝐿∗1 , 𝐿+1 and 𝐿𝑟𝑒𝑣𝑒𝑟𝑠𝑒
1 all are also REL
 (L2 ∩ L1) is always REL  If L1 and L2 are Recursive language, then ----
 (L1 – L2) is not necessarily REL  (L1 U L2)
 ̅̅̅𝐿1 is recursive  (L1 - L2)
 ̅̅̅𝐿2 is not REL  (L1 ∩ L2)
 𝐿∗1 , 𝐿+1 and 𝐿𝑟𝑒𝑣𝑒𝑟𝑠𝑒
1 all are also
Recursive language
THEORY OF COMPUTATION GATE 2024
 If ‘X’ be a regular language and Y = REL but not recursive language. Let W and Z be two languages such
that 𝑌̅ reduces to W and Z reduces to 𝑋̅ (reduction means the standard many – one reduction). So, W is not
REL and Z is recursive language

 PCP and MPCP problem:


 Post correspondence problem (PCP) is undecidable
 Modified Post correspondence problem (MPCP) is undecidable
 Post correspondence problem (PCP) and Modified Post correspondence problem (MPCP) over one symbol
(unary alphabet) is decidable problem

 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

 Equivalences of Regular Expression (or Regular Languages):


 L(R1 + R2) = L(R1) U L(R2)
 L(R1 . R2) = L(R1) . L(R2)
 L(a*) = (L(a))*
 a+a=a
 a.a≠a
 * = 
 ∅* = 
 a* . a* = a*
 a* . a+ = a+
 a . a* = a+
 (a*)* = a*
 (a)* = a*
  + aa* =  + a+ = a*
 a+ = a* - 
 a + ∑∗ = ∑∗
 a(ba)* = (ab)*a
 a(*) = a*
 (a*)a = a*
 aa.a* = a.a+
 (a + b)* = (a* b*)* = (a + b*)* = (a* (b*)*)* = a* (ba*)* = (b* a)* b* = (a* + b*)* = (a + b)*a*b* = (a + b + )+ =
(a*b*)+ = (b*a*)+ = (a* + b)+ = (a + b*)+
 (a + b + c)* = (a* + b* + c*)* = (a* b* c*)* = (a*b* + c*)*
THEORY OF COMPUTATION GATE 2024
 Regular Language Vs Regular Expression:
Regular language over ∑ = {a, b} Regular Expression
1 L={} ∅
2 L = {all strings of a’s and b’s} (a + b)* = ∑∗
3 L = {all strings start with a} a(a + b)*
4 L = {all strings end with a} (a + b)*a
5 L = {all strings start with a and end with b} a(a + b)*b
6 L = {all strings start with a or start with b} a(a + b)* + b(a + b)*
7 L = {all strings with atmost two length} (a + b + )(a + b + )
8 L = {all strings with atmost three length} (a + b + )(a + b + )(a + b + )
9 L = {all strings with atleast two length} (a + b)(a + b) (a + b)* = (a + b)(a + b)+
10 L = {all strings with atleast three length} (a + b) (a + b)(a + b)+
11 L = {all strings with exactly two length} (a + b)(a + b)
12 L = {all strings with exactly three length} (a + b) (a + b) (a + b)
13 L = {all strings containing ‘ab’ as a substring} (a + b)*ab(a + b)*
14 L = {all strings containing ‘aa’ as a substring} (a + b)*aa(a + b)*
15 L = {In all strings, every ‘a’ must followed by ‘b’} (b + ab)*
16 L = {All strings contain second symbol from LHS is ‘a’} (a + b)a(a + b)*
17 L = {All strings contain second symbol from RHS is ‘a’} (a + b)*a(a + b)
18 L = {all strings of even length} ((a + b)(a + b))*
19 L = {all strings of odd length} (a + b)((a + b)(a + b))*
20 L = {Every strings contain all a’s followed by b’s} a*b*
21 L = {all strings start and end with same symbol}  + a + b + a(a + b)*a + b(a + b)*b
22 L = {all strings start and end with different symbol} a(a + b)*b + b(a + b)*a
23 L = {all strings start and end with ‘a’} a + a(a + b)*a
24 L = {all strings start with ‘a’ and not having two consecutive ‘b’} (a + ab)+
25 L = {all strings which contain exactly one ‘a’} b*ab*
26 L = {all strings which contain exactly two ‘a’} b*ab*ab*
27 L = {all strings which contain exactly one ‘a’ or exactly one ‘b’s} b*ab* + a*ba*
28 L = {all strings which contain exactly two ‘a’ or exactly two ‘b’s} b*ab*ab* + a*ba*ba*
29 L = {all strings which contain atmost two ‘a’} b*( + a)b*( + a)b*
30 L = {all strings which contain atleast one ‘a’} (a + b)*a(a + b)*
31 L = {all strings which contain atleast two ‘a’} (a + b)*a(a + b)*a(a + b)* = b*ab*a(a + b)*
32 L = {all strings have atleast one ‘a’ or one ‘b’} (a + b)*a(a + b)* + (a + b)*b(a + b)*
33 L = {all strings have atleast one ‘a’ and one ‘b’} (a + b)*a(a + b)*b(a + b)* + (a + b)*b(a + b)*a(a + b)*
= (a + b)*ab(a + b)* + (a + b)*ba(a + b)*
34 L = {all strings where length of strings divisible by 3} ((a + b)(a + b)(a + b))*
35 L = {all strings contains even no. of ‘a’} (b*ab*ab*)*b* = (aa)* = b*(ab*ab*)*
= (b*ab*ab*)*
36 L = {all strings contains odd no. of ‘a’} (b*ab*ab*)b*ab* = a(aa)*
= (b*ab*ab*)*ab*
37 L = {all strings that start with double letter} (aa + bb)(a + b)*
38 L = {all strings that contains atleast one double letter} (a + b)* (aa + bb)(a + b)*
39 L = {all strings that contains atleast two consecutive ‘a’s} (a + b)*aa(a + b)*
40 L = {all strings that end with ‘aa’} (a + b)*aa
41 L = {all strings that does not end with ‘ba’} (a + b)*(aa + bb + ab)
42 L = {all strings that start and end with double letter} (aa + bb)(a + b)* (aa + bb)
43 L = {all even length strings of alternating a’s and b’s} (ab)* + (ba)*
44 L = {all strings contains two consecutive ‘a’ and two consecutive (a + b)*aa(a + b)*bb(a + b)* +
‘b’} (a + b)*bb(a + b)*aa(a + b)*
= (a + b)*(aa(a + b)*bb + bb(a + b)*aa)
THEORY OF COMPUTATION GATE 2024
 X followed by any number of A or B = X(A + B)*
 Any number of ‘a’ = a* = (aa)*(a + )
 (ab + c)* = ((ab)* + c*)*
 (ab*a) = Represent infinite set of finite string
 all strings that contains atleast one double letter
= (a + b)* (aa + bb)(a + b)* = [a(ba)*(a + bb) + b(ab)*(b + aa)](a + b)*

Its DFA is ------------- its NFA is ---------------------


THEORY OF COMPUTATION GATE 2024
 Regular Language: It is a language which is recognized by some Finite State Machine
 Properties of Regular Languages:
 If L is a regular language, then------------------------
 𝐿̅ is also a regular language means, regular language are closed under complement
 L* is also a regular language means, regular language are closed under kleene closure
 LR or reversal of language is also a regular language means, regular language are closed under
reversal

 If L1 and L2 are regular, then----------------------------


 L1 ∩ L2 is also a regular language means, regular language are closed under intersection
(Product automata)
 L1 U L2 is a regular language means, regular language are closed under union
 L1 – L2 is also a regular language
 L1 . L2 is also a regular language (concatenation)

 The set of regular languages(L) is closed under ---------------


 Union operation (L1 U L2)
 Intersection operation (L1 ∩ L2)
 Difference operation (L1 – L2)
 Complement operation (𝐿̅)
 Concatenation operation (L1 . L2)
 Kleene closure operation (L*)
 Positive closure operation (L+)
 Prefix operation [L = {u | uv is in regular language L}]
 Suffix operation [L = {v | uv is in regular language L}]
 Reversal operation (LR)
 Half of a regular language [L = {u | uv  L and |u| = |v|}]
 One third of a regular language [L = {u | uvw  L and |u| = |v| = |w|}]
𝐿1
 Quotient of two regular language [ = {x | xy  𝐿1 for some y  𝐿2 }
𝐿2
 Subsequence of a regular language [subsequence (L) = {w | w is obtained by removing symbols
from anywhere of a string in L}]
 Sub – word of a regular language [sub word (L) = {v | for some u and for some w, uvw is in L}]
 Homomorphism of two regular language
 Inverse Homomorphism of two regular language
 Substitution of two regular language
 Shuffle of two regular language [ shuffle(L1, L2) = {x1y1x2y2…..xkyk | x1x2…..xk is in L1 and
y1y2…..yk is in L2}]
 Symmetric difference of two regular language
 Square root (√𝐿) is also regular language [√𝐿 = {w | ww in regular language L}]
 Max (L) is also regular language
 Min (L) is also regular language [ min(L) = {w | w  L and there is no proper prefix of w is in L}]
 NOR & COR of two regular languages
 Finite subset of any language L is always regular (finite language)

 Regular language (L) are not closed under ---------------


 Subset
 Superset
 Infinite union
 Infinite intersection
 Infinite difference
 Infinite concatenation
THEORY OF COMPUTATION GATE 2024
 Notes on Regular Languages:
 Every finite language is regular
 Every infinite regular language contains an undecidable language as a subset
 ̅̅̅̅̅̅̅
In min. DFA with n – states accept L(m) then just by flipping states of same min. DFA it can accept 𝐿(𝑚)
 Every finite subset of non – regular set is regular
 Every finite subset of regular set is regular
 A finite language over some finite alphabet
 It is Turing machine recognizable
 It is a CSL
 It is a regular language
 Every language has a regular subset
 Every language has a regular superset
 Every subset of a finite language is regular
 Every regular language is also CFL
 If L is a regular language then ∑∗− L is always regular
 If R1 and R2 be regular set over the alphabet ∑ , then -----------
 ∑∗− R1 is always regular
 R1 U R2 is regular

 How to check Regular Language:


 Construct a regular expression
 Design a finite automata (FA) [for non – regular languages we cannot design finite automata]
 Use closure properties
 Apply the pumping lemma

 Pumping Lemma:
 Pumping lemma can be used to prove that a given language is non – regular (using proof by contradiction).

 Some Regular Language:


 L = { wxwR |w, x  {a, b}* & |w|, |x|>0}
 L = { ambn| m ≥ 1, n ≥ 1 } ----------- L ⊆ ∑∗ & ∑ ={a, b}
 L = { 02n | n is an integer or n ≥ 1}
 L = { 0m1n | 0 ≤ m ≤ n ≤ 10000}
 L = { w  {0, 1}* | w contains even no. of 0’s & even no. of 1’s}
 L = { anb2n| m ≥ 0, n ≥ 0}
 L = { xcy | x, y  {a, b}*}
 L = { w  {0, 1}* | w has at least as many occurrence of (110)’s as (011)’s}
 If L1 = { an | n ≥ 0} & L2 = { bn | n ≥ 0} are regular languages then L = L1 . L2 = { an bm | n, m ≥ 0} is also a
regular languages
 L = { w | w has 3k + 1 b’s for some k  N with ∑ = {a, b}}
 L = { aPbQcR | P, Q, R ≥ 0}
 L = { 1, 2, 4, 8, ……….2n……} = {1, 10, 100, 1000,………..} = 10*
 L = { wxwR |w, x  {0, 1}*}
 L = { wxwR |w, x  {0, 1}+}
 L = { wxw |w, x  {0, 1}*}
 L = { xww |w, x  {0, 1}*}
 L = { anbn | n ≤ 10000}
 L = { anbncn | n = 10}
2
 L = { 𝑎𝑛 | n  0}*
 L = { a*} over ∑ = {a}
 L = { a*b*}
 L = { anbm| m, n ≥ 0} = a*b*
 L = { anbm| m < n < 10} --------[Finite set, Regular language]
 L = { anbm| m = n, m < 10}
 L = { ambn| LCM (m, n) = 1}
 L = { ambn| m = even, n = odd}
THEORY OF COMPUTATION GATE 2024
 L = { a2n | n  0} = (aa)* over ∑ = {a}
𝑛
 L = { 𝑎2 | n ≤ 10}
 L = { aprime}* over ∑ = {a}
 L = complement of {a} = ∑∗ - {a} = { , a2, a3, a4, a5, a6, a7, …..}
 L = { aprime| prime < 100} is finite language
 L = { wxw | w  {a, b}*, x  {a, b}+} put w =  and x = (a + b)+ ; then L = (a + b)+
 L = { xww | w  {a, b}*, x  {a, b}+}; L = (a + b)+
 L = { wwRx | w  {a, b}*, x  {a, b}+}; L = (a + b)+
 L = {wxwR | w  (a + b)*, x  {a, b}+}; L = (a + b)+
 L = { xwwR | w  {a, b}*, x  {a, b}+}; L = (a + b)+
 L = {anbnck | n, m, k  0} = a*b*c*

 Some Non - Regular Language:


 L = {ambm | i ≥ 0}
 L = {aPrime } over ∑ = {a}
 L = { ambn | m > n}
 L = { anbm | m > n > 10}
 L = { anbm | m = n, m > 10}
 L = { ambn | m < n}
 L = { anbn | n  0}
 L = { ambn | GCD(m, n) = 1}
 L = { ambn | m ! = n}
 L = { w | w𝜖(a + b)*} and w has #a’s equal to #b’s}
 L = { ww | w𝜖(a + b)*}
2
 L = { 𝑎𝑛 | n  0} over ∑ = {a}
𝑛
 L = { 𝑎2 | n > 0} over ∑ = {a}
 L = { anbncn}
 L = { anb2n | n  0}
 L = { anbmcn | n, m  0}
 L = { anbmcn+m | n, m  0}
 L = { anbncn | n  0}
 L = { wwR | w  {a, b}*}
 L = { ambn | m = n = even}
 L = { a2nb2n | n = even}
 L = { an! | n  100} over ∑ = {a}
 L = { 𝑎𝑛 𝑛 | n  10} over ∑ = {a}
 L = { w#w | w  a*}
 L = { w#wR | w  a*}
 L = { w#w | w  (a + b)*}
 L = { wwR | w  (a + b)*}
 L = { ww | w  (a + b)*}
THEORY OF COMPUTATION GATE 2024
 Deterministic Finite Automata (DFA):
At every state there should be unique transition for every input symbol

1. L = { ∅} = language is empty over ∑ = {a, b}

2. L = {} = language accept only null value or null string

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}*}

4. L = { aw | w  {a, b}*} = every string starting with a

5. L = { bw | w  {a, b}*} = every string starting with b


THEORY OF COMPUTATION GATE 2024
6. L = { abw | w  {a, b}*} = every string starting with ab

7. L = every string starting with aa or bb

8. L = { wa |w {a, b}*} = every string ending with a

9. L = { wb |w {a, b}*} = every string ending with b

10. L = { waa |w {a, b}*} = every string ending with aa

11. L = { wbb |w {a, b}*} = every string ending with bb


THEORY OF COMPUTATION GATE 2024
12. L = { waaa |w {a, b}*} = every string ending with aaa

13. L = { wab |w {a, b}*} = every string ending with ab

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)

20. L = every string contain ab as a sub-string

21. L = every string contain a

22. L = every string contain exactly 2a

23. L = every string contain atleast 2a


THEORY OF COMPUTATION GATE 2024
24. L = every string contain atmost 2a

25. L = {w | W contain 3 consecutive a’s, w  {a, b}*}

26. L = In each string, every a should followed by b

27. L = In each string, a never followed by b

28. L = In each string, every a followed by bb

29. L = In each string, a never followed by bb

30. L = In each string, all a followed by all b = {ambn | m, n  0}

31. L = In each string, all a followed by single b = {amb | m  0}


THEORY OF COMPUTATION GATE 2024
32. L = { w | every occurrence of aa is followed by a ‘b’ in each w, w  {a, b}*}

33. L = { even no. of a’s }

34. L = { odd no. of a’s }

35. L = { w | w contains a in every odd position}; RE = (a(a + b))*( + a)

36. L = { w | w contains a in every even position}

37. L = {length of string exactly 3}

38. L = {length of string atleast 3}


THEORY OF COMPUTATION GATE 2024
39. L = {length of string atmost 3}

40. L = {length of string is even} / |W| ≅ 0 mod 2

41. L = {length of string is odd} / |W| ≅ 1 mod 2

42. L = |W| ≅ 0 mod 3 / |W| mod 3 = 0

43. L = |W| ≅ 1 mod 3

44. L = |W| ≅ 2 mod 3

45. L = |W| mod 3  1

46. L = { w  {a, b}* | #a(w) mod 2 = 0}


THEORY OF COMPUTATION GATE 2024
47. L = { w  {a, b}* | #a(w) mod 3 = 0}

48. L = { w  {a, b}* | #a(w) mod 3 = 1 or (3k + 1)}

49. L = { w  {a, b}* | #a(w) mod 5 ≤ 2}

50. L = { w | w  {0, 1}*} = {, 0, 1, 00, 11, 01, 10, …} = language accept all binary strings

51. L = every string contain 00 as a sub-string

52. L = every string contain 000 as a sub-string

53. L = each string not contain 000

54. L = { set of all string over {0, 1} divisible by 3 in binary pattern}


THEORY OF COMPUTATION GATE 2024
55. L = { set of all string over {0, 1} divisible by 4 in binary pattern}

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}

57. L = { w | w  {0, 1}* and last two bits are different}

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}

63. L = { an | n  1 & n ≠ 1, 3} or L = { an | n > 0 & n ≠ 1, 3}

64. L = { anbm | n, m  0} = any no. of a followed by any no. of b

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

66. L = { ambn | n, m > 0} or L = { ambn | m  1, n  1 }

67. L = { amb | m  0}

68. L = { ambn | m = 2, n = 1 }
THEORY OF COMPUTATION GATE 2024
69. L = { ambn | m ≤ n < 2 }

70. L = {wxwR | x  {a, b}+, w  {a, b}*} = (a + b)+

71. L = { wxwR | x  {a, b}+, w  {a, b}+}

 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 ----

1. If there is more than one transition for single input.


2. Or, there is  - moves present
 Example of NFA:
1. L = {W00 | W  {0, 1}*} = { set of all strings over {0, 1} ending with 00}

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}

4. L = { set of all strings over {0, 1} ending with either 00 or 11}

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

Present Input [x = 0] Input [x = 1]


state (PS) Next Output Next Output
state state
a a 0 b 0
b b 1 c 0
c d 0 c 1
d b 0 a 1

Present Input Input Output


[x = 0] [x = 1]
state (PS)
Next Next
state state
a a b 0
b b c 0
c d c 0
d d a 1
THEORY OF COMPUTATION GATE 2024
THEORY OF COMPUTATION GATE 2024
Regular Language / Regular Expression No. of states
L = { w  {0, 1}* | w does not contain 3 or more consecutive 1’s} 4
L = { string not end with 101} 4
L = { x  {a, b}* | no. of a’s in x divisible by 2 but not divisible by 3} 2*3=6
L = { w |w  {0, 1}* , no. of 0 divisible by 2 & no. of 1 divisible by 5} 2 * 5 = 10
L = { W1 a W2 | W1 & W2  {a, b}*, | W1| = 2; | W2|  3} 8
RE = (a + b)*b(a + b) 4
RE = (0 + 1)*(0 + 1) (0 + 1)* 2
L(RE) = ∑∗ 0011 ∑∗ and L’(RE) 5
RE = (0 + 1)*(10) 3
L = (111 + 11111)* 9
L = { x | |x| divisible by 3} 3
L = { an | n is odd/even} 2
RE = (0 + 1) (0 + 1) (0 + 1)………….. n times (n + 1)
RE = (0 + 1)*(00 + 11) 5(DFA) & 4(NFA)
L = { ank | k > 0 & n is a +ve integer constant} ( n + 1)
L = { an | n  0 & n ≠ k ,where k is a +ve integer constant} Total state = ( k + 2)
Non final state = qk
L = { an | n  0 & n ≠ k1 , k2, k3, ……km} where k1 < k2 < k3< …<km & all are +ve Totat state = km + 2
integer Non final state = m
Final state = km + 2 -
m
L = { wn | w  {a, b}* & n is +ve integer constant of fixed length string} ( n + 1)
L = { w  {a, b}*|no. of a mod n ≤ k} where k is a +ve integer & k < n Total state = n
Final state = (k + 1)
Non final state = n –
(k+1)
L = { w  {a, b}*| |w| = n, where n = +ve integer constant} (n + 2)
If length of string = n (|w| = n) or L = { w |w  {a, b}*, |w| = n} (n + 1) in NFA
(n + 2) in DFA
If length of string is atmost n (|w| ≤ n) or L = { w |w  {a, b}*, |w| ≤ n} (n + 1) in NFA
(n + 2) in DFA
If length of string is atleast n (|w|  n) or L = { w |w  {a, b}*, |w|  n} (n + 1) in NFA
(n + 1) in DFA
L = { w |w  {a, b}*, w starts with a} 2 in NFA
3 in DFA
L = { w |w  {a, b}*, nth symbol from begin is a} (n + 1) in NFA
(n + 2) in DFA
L = { w |w  {a, b}*, nth symbol from end is a} (n + 1) in NFA
2n in DFA

 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

 S -> aS | Sa | b [not LLG, not RLG; so, it is not RG]


 S -> abc [both LLG & RLG]
 L (RG) = L (LLG) = L (RLG)

 Derivation of string: Derivation of a string


from a grammar is calculated by Parse tree.
It can occur by two way, Left most derivation
(LMD) and Right most derivation (RMD)

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}

 Odd length palindrome:


 S -> a S a | b S b | a | b
 L = {w (a + b) wR | w  {a, b}* }
 L = {w x wR | w  {a, b}*, x  {a, b}}
 L = {set of all odd length palindromes over ∑ = {a, b}}

 All palindrome:
 S -> a S a | b S b | a | b | 

 Every string (w) generated by CFG has exactly one derivation


(#parse tree’s = #LMD’s = #RMD’s) = 1
 A CFG is ambiguous if at least one string has more than one parse tree
(#parse tree’s = #LMD’s = #RMD’s) > 1

 Closure properties of CFL’s: 3. Set difference


The context free languages are closed under ---- 4. Symmetric difference (XOR)
1. Union 5. NAND, NOR
2. Finite union 6. Subset
3. Concatenation 7. Finite intersection
4. Finite concatenation 8. Finite difference
5. Finite subset 9. Infinite union
6. Kleene closure 10. Infinite intersection
7. Kleene plus 11. Infinite Subset
8. Reversal operation 12. Infinite substitution
9. Homomorphism 13. Infinite difference
10. Inverse homomorphism 14. Infinite concatenation
11. Substitution 15. Superset
12. Suffix & prefix operation 16. Quotient
13. Cycle operation 17. Reg – L
14. Union with RL
15. Intersection with RL  Closure properties of DCFL’s:
16. Difference with RL The deterministic context free languages are
17. Substring closed under -------
18. Substitution 1. Complement
19. Finite substitution 2. Prefix
20.  - free homomorphism 3. Inverse homomorphism
21. Inverse homomorphism 4. Finite subset
22. L – Reg 5. Union with regular
6. L – Regular
The context free languages are not closed under ----
7. Regular – L
1. Intersection 8. L U Regular
2. Complement
THEORY OF COMPUTATION GATE 2024
 CFL’s:  L = {ambncpdq | m + p = n + q, where m, n, p, q
 L = {anbn | n ≥ 1}[not regular]  0}
 L = {anbnCm | m, n ≥ 1}[not regular]  L = {ambncpdq | m = n & p = q, where m, n, p, q
 L = {anbnCm | m, n ≥ 0}  0}
 L = {anbmCn | m, n ≥ 0}  L = {ambnanbm | m, n  1}
 L = {ambm+nCn | m, n ≥ 1}[not regular]  L = {ambn | m = 2n + 1}
 L = {anb3n | n ≥ 1}[not regular]  L = {ambn | m ≠ n}[not regular]
 L = {w  (a + b)* | #a(w) = #b(w)} [not regular]
 L = {all strings of balanced parenthesis}[not
regular]  Non – CFL’s:
 L = {wwR | w  (a + b)+} [not regular]  L = {anbnCn | n ≥ 0}
L = { 𝑎𝑛 | n  0}
2
 L = {wcwR | w  (a + b)+} [not regular] 
 L = {wcwR | w  (a + b)*} [not regular]  L = { an | n is prime}
𝑛2
 L = {ambmCndn | m, n ≥ 0}[not regular]  L = {𝑎 2 | n  0}
 L = {ambnCndm | m, n ≥ 0}[not regular]  L = {wwRwR | w  (a + b)*}
 L = {am+n bn+k ck+m | m, n ≥ 0}  L = { 0p | p is composite}
 L = {ambnCm+n | m, n ≥ 1} [not regular]  L = {anbnCi | i ≤ n}
 L = {anbmCm+n | m, n ≥ 1}  L = {anbnCi | i ≠ n}
 L = {0i1j | i = j}  L = {anbmCndm | m, n ≥ 0}
 L = {0i1j | i ≠ j}  L = { 𝑎2 | n  0}
𝑛

 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

 L = {anbn | n ≥ 1}  L = {ww | w  (0, 1)*}


 L = {anb2n | n ≥ 0} [DCFL but not regular]  L = {wwRw | w  (0, 1)*}
 L = {a2nbn | n ≥ 0} [DCFL]
 L = {xww | x w  (0, 1)+}
 L = {a2nb2n | n ≥ 0} [DCFL] 𝑛𝑎 (𝑤)
 L = {w | = 𝑛𝑐 (w)}
 L = {anbnc*} assume always n ≥ 0 in all example 𝑛𝑏 (𝑤)
[DCFL but not regular]  L = {anbmcp | n = m and m = p}
2
 L = { ambnc* | m = n} [DCFL but not regular]  L = {an 𝑏 𝑛 }
 L = {anb*cn}[DCFL]  L = {anbncn}
 L = {a*bncn}[DCFL]  L = {anbmcp | n = m = p}
 L = { ambnc* | m ≠ n}[DCFL]  L = {wwRwR | w  (0, 1)*}
 L = { ambnc* | m < n}[DCFL]  L = {w | na(w) = nb(w) = nc(w)}
 L = { ambnc* | m > n}[DCFL]  L = {anbmcndm}
 L = { ambnc* | m ≤ n}[DCFL]
 L = { ambnc* | m  n}[DCFL]
 L = { anbncm | m, n ≥ 0}[DCFL]
 L = { ambncn | m, n ≥ 0}[DCFL]
 L = {ambncm+n | m, n ≥ 0}[DCFL]
 L = {wwR | w belongs to {a, b}*} is CFL but not DCFL
 L = {0i21i | i  0} [ Recursive and DCFL]
 L = {w#wR | w  {0, 1}*}
 L = {0n | 1n| n  0}
 L = {wcwR | w  {0, 1}*}

 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

Class Formal languages Grammars Automata


Type – 3 Regular Languages Regular Grammars Finite Automata
Type – 2 Context Free Languages Context Free Grammars Push down Automata
Type – 1 Context Sensitive Languages Context Sensitive Grammars Linear bound Automata
Type – 0 Recursive Enumerable Languages Recursive Enumerable Turing machine
Grammars / Unrestricted
Grammars

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

You might also like