SlideShare a Scribd company logo
1 of 36
1
 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
 In automata theory, a formal language is a set of strings of symbols drawn from
a finite alphabet.
3
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
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
 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
 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
 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
 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
 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
11
 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
 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
Describe the relationship among grammar types?
14
Design a context-free grammar for the language L = {0^n 1^n | n ≥
1}.
15
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
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
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
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
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
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
REDUCIBILITY
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?
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
 Assume we have the state-entry algorithm:
 We want to design the halting problem
 Modify input machine M:
 Add new state q
 From any halting state add transition to q
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
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.
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
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
Name some of the examples of NP problems?
33
What the time complexity T(n) for the Turing Machine M
which accepts the language {0n1n|n≥1}?
34
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
 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

More Related Content

Similar to hghghghhghghgggggggggggggggggggggggggggggggggg

Presentation (5).pdf
Presentation (5).pdfPresentation (5).pdf
Presentation (5).pdfGaurav447273
 
practice-final-soln.pdf
practice-final-soln.pdfpractice-final-soln.pdf
practice-final-soln.pdfT17Rockstar
 
Types of Language in Theory of Computation
Types of Language in Theory of ComputationTypes of Language in Theory of Computation
Types of Language in Theory of ComputationAnkur Singh
 
Lecture: Regular Expressions and Regular Languages
Lecture: Regular Expressions and Regular LanguagesLecture: Regular Expressions and Regular Languages
Lecture: Regular Expressions and Regular LanguagesMarina Santini
 
The Theory of Finite Automata.pptx
The Theory of Finite Automata.pptxThe Theory of Finite Automata.pptx
The Theory of Finite Automata.pptxssuser039bf6
 
theory of computation lecture 02
theory of computation lecture 02theory of computation lecture 02
theory of computation lecture 028threspecter
 
language , grammar and automata
language , grammar and automatalanguage , grammar and automata
language , grammar and automataElakkiyaS11
 
theory of computation notes. introduction and mcq points
theory of computation notes. introduction and mcq pointstheory of computation notes. introduction and mcq points
theory of computation notes. introduction and mcq pointsbushraphd2022
 
Formal Languages and Automata Theory unit 5
Formal Languages and Automata Theory unit 5Formal Languages and Automata Theory unit 5
Formal Languages and Automata Theory unit 5Srimatre K
 

Similar to hghghghhghghgggggggggggggggggggggggggggggggggg (20)

Presentation (5).pdf
Presentation (5).pdfPresentation (5).pdf
Presentation (5).pdf
 
Ch11.ppt
Ch11.pptCh11.ppt
Ch11.ppt
 
Ch11.ppt
Ch11.pptCh11.ppt
Ch11.ppt
 
practice-final-soln.pdf
practice-final-soln.pdfpractice-final-soln.pdf
practice-final-soln.pdf
 
Types of Language in Theory of Computation
Types of Language in Theory of ComputationTypes of Language in Theory of Computation
Types of Language in Theory of Computation
 
Lecture: Regular Expressions and Regular Languages
Lecture: Regular Expressions and Regular LanguagesLecture: Regular Expressions and Regular Languages
Lecture: Regular Expressions and Regular Languages
 
rs1.ppt
rs1.pptrs1.ppt
rs1.ppt
 
QB104541.pdf
QB104541.pdfQB104541.pdf
QB104541.pdf
 
10651372.ppt
10651372.ppt10651372.ppt
10651372.ppt
 
Unit ii
Unit iiUnit ii
Unit ii
 
Regular Grammar
Regular GrammarRegular Grammar
Regular Grammar
 
The Theory of Finite Automata.pptx
The Theory of Finite Automata.pptxThe Theory of Finite Automata.pptx
The Theory of Finite Automata.pptx
 
theory of computation lecture 02
theory of computation lecture 02theory of computation lecture 02
theory of computation lecture 02
 
Module 1 TOC.pptx
Module 1 TOC.pptxModule 1 TOC.pptx
Module 1 TOC.pptx
 
Flat
FlatFlat
Flat
 
PART A.doc
PART A.docPART A.doc
PART A.doc
 
language , grammar and automata
language , grammar and automatalanguage , grammar and automata
language , grammar and automata
 
theory of computation notes. introduction and mcq points
theory of computation notes. introduction and mcq pointstheory of computation notes. introduction and mcq points
theory of computation notes. introduction and mcq points
 
Formal Languages and Automata Theory unit 5
Formal Languages and Automata Theory unit 5Formal Languages and Automata Theory unit 5
Formal Languages and Automata Theory unit 5
 
Fafl notes [2010] (sjbit)
Fafl notes [2010] (sjbit)Fafl notes [2010] (sjbit)
Fafl notes [2010] (sjbit)
 

Recently uploaded

SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Bluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfBluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfngoud9212
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentationphoebematthew05
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 

Recently uploaded (20)

SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Bluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfBluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdf
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentation
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 

hghghghhghghgggggggggggggggggggggggggggggggggg

  • 1. 1
  • 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
  • 11. 11
  • 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
  • 14. Describe the relationship among grammar types? 14
  • 15. Design a context-free grammar for the language L = {0^n 1^n | n ≥ 1}. 15
  • 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
  • 25.  Assume we have the state-entry algorithm:
  • 26.  We want to design 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
  • 33. Name some of the examples of NP problems? 33
  • 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