2. An alphabet is a finite nonempty set of symbols. Symbols are assumed to be
indivisible
A string over an alphabet Σ is a finite sequence of symbols of Σ .
The number of symbols in a string x is called its length, denoted by |x|. It is
convenient to
Introduce a notation ε for the empty string, which contains no symbols at all.
The length of ε is 0.
The set of all strings over an alphabet Σ is denoted by Σ*.
The expression 0(0 + 1)1 represents the set of all strings that begin with a 0
and end with a 1.
2
3. In automata theory, a formal language is a set of strings of symbols drawn from
a finite alphabet.
3
4. REGULAR EXPRESSIONS
Regular expressions are mathematical tool designed to represent regular
languages.
The languages accepted by some regular expression are referred to as Regular
languages.
A regular expression can also be described as a sequence of pattern that defines
a string.
In a regular expression, x* means zero or more occurrence of x. It can generate
{e, x, xx, xxx, xxxx, .....}
In a regular expression, x+ means one or more occurrence of x. It can generate
{x, xx, xxx, xxxx, .....}
4
5. 1. Write the regular expression for the language accepting all the
string containing any number of a's and b’s.
2. Write the regular expression for the language accepting all the string which
are starting with 1 and ending with 0, over ∑ = {0, 1}.
5
6. According to Noam Chomosky, there are four types of grammars − Type 0, Type 1, Type 2,
and Type 3.
Take a look at the following illustration. It shows the scope of each type of grammar
6
7. Type-3 grammars generate regular languages. Type-3 grammars must have a single non-
terminal on the left-hand side and a right-hand side consisting of a single terminal or single
terminal followed by a single non-terminal.
The productions must be in the form X → a or X → aY
where X, Y ∈ N (Non terminal)
and a ∈ T (Terminal)
The rule S → ε is allowed if S does not appear on the right side of any rule.
7
8. Type-2 grammars generate context-free languages.
The productions must be in the form A → γ
where A ∈ N (Non terminal)
and γ ∈ (T ∪ N)* (String of terminals and non-terminals).
These languages generated by these grammars are be recognized by a non-deterministic
pushdown automaton.
8
9. Type-1 grammars generate context-sensitive languages. The productions must be in the form
α A β → α γ β
where A ∈ N (Non-terminal)
and α, β, γ ∈ (T ∪ N)* (Strings of terminals and non-terminals)
The strings α and β may be empty, but γ must be non-empty.
The rule S → ε is allowed if S does not appear on the right side of any rule. The languages
generated by these grammars are recognized by a linear bounded automaton.
9
10. Type-0 grammars generate recursively enumerable languages. The productions have no
restrictions. They are any phase structure grammar including all formal grammars.
They generate the languages that are recognized by a Turing machine.
The productions can be in the form of α → β where α is a string of terminals and nonterminals
with at least one non-terminal and α cannot be null. β is a string of terminals and non-
terminals.
10
12. We now understand that a grammar should have the following components.
A set of nonterminal symbols.
A set of terminal symbols.
A set of rules.
As the grammar is to construct/validate sentences of a language, we
distinguish a symbol in the set of non-terminals to represent a sentence from
which various sentences of the language can be generated/validated.
12
13. Let G = (V,T,S,P) be a grammar with T = {a,b} and P = {S -> ABa, A -> BB, B
-> ab, AB -> b}.
S => ABa => BBBa => abBBa => ababBa => abababa S => ABa => Aaba => BBaba =>*
abababa
S => ABa => ba
L(G) = { ba, abababa }
13
16. Very powerful (abstract) machines that could simulate any modern day
computer (although very, very slowly!)
Invented by Alan Turing in 1936.
It is capable of performing any calculation which can be performed by any
computing machine.
16
17. A TM can be formally described as a 7-tuple (Q, ᴦ, ∑, δ, q0, B, F) where −
Q is a finite set of states
ᴦ is the tape alphabet
∑ is the input alphabet
δ is a transition function; δ : Q × ᴦ → Q × ᴦ × {Left_shift, Right_shift}.
q0 is the initial state
B is the blank symbol
F is the set of final states
17
18. 1. Design a Turing Machine to recognize the language L=(0|1)*1.
Example :- 0101,0011
2. Design a Turing Machine which recognizes the language L= 01*0.
18
19. A problem is decidable if we can construct a Turing machine which
will halt in finite amount of time for every input and give answer as
‘yes’ or ‘no’. A decidable problem has an algorithm to determine
the answer for a given input.
A problem is undecidable if there is no Turing machine which will
always halt in finite amount of time to give answer as ‘yes’ or ‘no’.
An undecidable problem has no algorithm to determine the answer
for a given input.
19
20. Language A is reducible to language B (represented as A≤B)
if there exists a function f which will convert strings in A to
strings in B as:
w ɛ A <=> f(w) ɛ B
Theorem 1: If A≤B and B is decidable then A is also
decidable.
Theorem 2: If A≤B and A is undecidable then B is also
undecidable.
20
21. RECURSIVE
LANGUAGE(REC)
A language ‘L’ is said to be recursive if there exists a Turing machine which
will accept all the strings in ‘L’ and reject all the strings not in ‘L’. The Turing
machine will halt every time and give an answer(accepted or rejected) for each
and every string input.
Recursively enumerable language(RE)
A language ‘L’ is said to be a recursively enumerable language if there exists a
Turing machine which will accept (and therefore halt) for all the input strings
which are in ‘L’ but may or may not halt for all input strings which are not in
‘L’. By definition , all REC languages are also RE languages but not all RE
languages are REC languages.
21
23. The halting problem is reduced to state-entry problem
State-entry problem
Input: Turing machine M
State q
String w
Question: does a Turing machine M enter state q on input w?
24. Theorem: state-entry problem is undecidable.
Proof: Reduce the halting problem to the state-entry
problem
Suppose we have an algorithm(turing machine) that solves
the state-entry problem.
We will construct an algorithm that solves the halting
problem
27. Modify input machine M:
Add new state q
From any halting state add transition to q
28. M halts if and only if M’ halts on state q
Algorithm for halting problem:
Inputs: machine M and string w
1. Construct machine M’ with state q
2. Run algorithm for state-entry problem with inputs: M’,q, w
29.
30. We reduced the halting problem to the state-entry problem
Since the halting problem is undecidable, it must be that
the state-entry problem is also undecidable.
31. P stands for the class of problems that can be solved by a deterministic
algorithm (i.e. by a Turing machine that halts) in polynomial time.
NP stands for the class of problems that can be solved by a nondeterministic
algorithm (that is, by a nondeterministic TM) in polynomial time.
P stands for polynomial and NP for nondeterministic polynomial.
31
32. NP-Hard Problems
A problem is said to be NP-Hard when an algorithm for
solving NP Hard can be translated to solve any NP
problem. Then we can say, this problem is at least as hard
as any NP problem, but it could be much harder or more
complex.
32
34. What the time complexity T(n) for the Turing Machine M
which accepts the language {0n1n|n≥1}?
34
35. Theorem 1: If there is a polynomial time reduction from P1 to P2 and if P2 is in
P then P1 is in P.
Definition: Let L be a language or problem in NP. Then L is NP – complete
if
1. L is in NP
2. For every language L' in NP there exists a polynomial-time reduction from
L' to L.
Note: The class of NP – complete languages is a subclass of NP.
35
36. Theorem 2:If P1 is NP – complete, and there is a polynomial-time reduction of
P1 to P2, then P2 is NP – complete.
Theorem 3: If some NP – complete problem is in P, then P = NP.
Proof: Let P be an NP – complete problem and P ∈ P. Let L be any NP –
complete problem. By definition, there is a polynomial-time reduction of L to P.
As P is in P, L is also in P by Theorem 1. Hence NP = P.
SAT is NP-Complete.
36