SlideShare a Scribd company logo
1 of 42
P, NP, PS, and NPS
By Muhannad Harrim
Class P
 P is the complexity class containing decision problems which
can be solved by a Deterministic Turing machine (DTM) using a
polynomial amount of computation time, or polynomial time.
 P is often taken to be the class of computational problems
which are "efficiently solvable" or "tractable“.
 But P also contains problems which are intractable in practical
terms; for example, some require at least n¹ºººººº operations
Deterministic Turing machine (DTM)
DTM is:
 A Turing machine model (basic symbol-manipulating
device which, despite its simplicity, can be adapted
to simulate the logic of any computer).
 Consists of a finite state control, a read/write head,
and a tape made up of a two-way infinite sequence
of tape squares (or cells).
Deterministic Turing machine (DTM)
Deterministic Turing machine (DTM)
 Hopcroft and Ullman define a one-tape Turing
machine formula: M=(Q, Γ, b, ∑, δ, qo, F) where:
 Q is a finite set of states
 Γ is a finite set of the tape alphabet/symbols
 b is the blank symbol (the only symbol allowed to occur on the tape
infinitely often at any step during the computation) - Delimiter
 Σ, a subset of Γ not including b is the set of input symbols
 δ = Q x Γ  Q x Γ x {L,R} is a partial function called the transition
function, where L is left shift, R is right shift.
 qo is the initial state
 F is the set of final or accepting states
Deterministic Turing machine (DTM)
 A DTM program M with alphabet ∑ accepts
any x: x є ∑* iff M halts in the acceptance
final state (qY) when applied input x.
 The language LM recognized by the
program M as the following:
LM = { x є ∑* : M accepts x }
Class P & DTM
A formal definition for Class P with respect to
DTM would be given as follows:
P = { L: there is a polynomial time DTM
program M for which L = LM }
Class P & DTM
Conclusion:
A decision problem π belongs to P under the
encoding scheme e if L(π, e) belongs to P,
that is if there is a polynomial time DTM that
solves π under encoding scheme e.
Class NP
The class NP is defined informally to be the class of
all decision problems π which, under reasonable
encoding schemes, can be solved “verified” by
polynomial time using Non-Deterministic Turing
machines (NDTM).
- Polynomial time verifiability doesn’t imply
polynomial time solvability.
Nondeterministic Turing machine
(NDTM)
NDTM model has exactly the same structure
of DTM except it’s featured with a guessing
module that has its own write only head.
The guessing module’s main purpose is
providing the means for writing down the
“guess” into the tape.
Nondeterministic Turing machine
(NDTM)
Nondeterministic Turing machine
(NDTM)
NDTM is also specified exactly the same way
as DTM with respect to tape alphabet, input
alphabet, blank symbol, states set, initial and
final states, and the transition function.
However, It differs from DTM in the
computation process, where in NDTM it
takes two stages: the guessing and the
checking.
Nondeterministic Turing machine
(NDTM)
If NDTM program stops at a qY then, then the
computation is considered as an accepting
computation.
Otherwise, All other computations (halting or
not) are considered to be a non-accepting
computation.
Nondeterministic Turing machine
(NDTM)
Also, a NDTM will have an infinite number of
possible computations for a given input
string x.
NDTM accepts x iff at least one of the
possible structures (computations) is an
accepting one.
LM = { x є ∑* : M accepts x }
Class NP and NDTM
A formal definition for Class NP in respect to
NDTM :
NP = { L : there is a polynomial time NDTM
program M for which LM = L }
Class NP and NDTM
Conclusion :
A decision problem π belongs to NP under
the encoding scheme e if L(π, e) belongs to
NP, that is if there is a polynomial time NDTM
that “solves” (verifies) π under encoding
scheme e.
Class P and Class NP
Class P and Class NP
A controversial question:
Is P = NP ?
Polynomial Space (PS)
 The emphasis on the computation resources
is usually on the time used to perform the
computation process (especially when
measuring a performance issue or
complexity).
 However, the amount of space required is
often just as important ( called the space
requirement ).
Polynomial Space (PS)
In any Turing machine:
– the time used is the number of steps taken before
halting or entering a final state.
– The space required is defined as the number of
distinct tape squares (cells) “visited” by the
read/write head.
Polynomial Space (PS)
Proof
Since the time taken to visit all cells < = the time used, then
the number of cells visited < = the time used.
 the number of cells visited cannot be more than the steps of
computation
This implies:
Any Polynomial Solvable in polynomial time, It’s
solvable in polynomial space.
Polynomial Space (PS)
Although all problems solvable in polynomial
time can be solved in polynomial space, it is
still a controversial and unresolved question
whether there exist problems solvable in
polynomial space which cannot be solved in
polynomial time.
- This is so difficult to conclude since all problems in NP,
including P and NP-C problems are solved in both polynomial
space and polynomial time.
Polynomial Space (PS)
 PS
is the class of all languages recognizable by
polynomial space bounded DTM that halts
on all inputs.
i.e. All and Only the languages that are LM
for some polynomial space bounded DTM M.
Nondeterministic Polynomial Space
(NPS)
 NPS
is the class of all languages recognizable by
polynomial space bounded NDTM that halts
on at least one of the possible input
structures.
i.e. All and Only the languages that are LM
for some polynomial space
bounded NDTM M.
PS and NPS
Evidently, PS є NPS, since every DTM is
technically NDTM.
However, The surprising result is that:
PS = NPS
PS and NPS
Theorem
If M is a polynomial-space bounded TM
(deterministic or nondeterministic), and p(n)
is its polynomial space bound, then there is a
constant c such that if M accepts its input w
of length n, it does so within c1 + p(n) moves
PS and NPS
Proof
The essential idea is that M must repeat an ID (cell index) before
making more than c1 + p(n) moves
Having a constant c implies that there is a limited number of ID’s if
already there is a limited space used in the TM.
Let t be the number of tape symbols of M
Let s be the number of states of M
Then the number of different ID’s of M when only p(n) tape cells are
visited is at most s x p(n) x t p(n)
PS and NPS
if c = t + s, then the binomial expansion of
(t + s)1 + p(n) is t1+ p(n) + (1 + p(n)) s t p(n) + …
In the expression, notice that the underlined
term is at least as large as s p(n) t p(n)
This proves that c1 + p(n) is at least equal to
the number of possible ID’s of M
PS and NPS
M accepts w of length n with sequence of
moves that doesn’t repeat any ID
So  M accepts inputs by a sequence of
moves that is less or equal to the number of
distinct ID’s, which is c1 + p(n)
PS and NPS
Savitch’s Theorem
PS = NPS
PS and NPS
To be more accurate
Savitch’s Theorem states that any
p(n)-space NDTM can be converted to a
p2(n)-space DTM
one of the earliest results on space complexity
PS and NPS
Proof
The core of the proof lies on simulating a
NDTM that has a polynomial space bound
p(n) into a DTM with polynomial space bound
of complexity O( p2(n) )
PS and NPS
This is done through a recursive program that
tries to test whether a NDTM N can move
from ID I to ID J in at most m moves
Let’s have a function called reach(I, J, m)
that decides if I can yield to J in m moves
PS and NPS
PS and NPS
PS and NPS
Assumptions
– If NDTM N accepts, it does it within c1 + p(n) steps
– Given input w of length n
– DTM D discovers what N does with input w by
calling the function reach(I0,J,m) recursively where:
 I0 is the initial ID of N with input w
 J is any accepting ID that uses at most p(n) tape cells
 m = c1 + p(n)
PS and NPS
the recursive function imposes that there will never be
more than log2 m recursive calls that are active
simultaneously
i.e one with m/2, one with m/4, … , down to 1
 So, the upper bound of the number of stack
frames is no more than log2(m) on the stack
 log2(m) is O( p(n) )
PS and NPS
 So, D contains at most log2(m) stack frames = (O( pn ))
 The stack frames themselves require log2(m) space,
the reason is that the two ID’s each require only 1+p(n)
cells to write down m, and m in binary requires log2
c1 + p(n)  log2(m) = (O( pn ))
 The total space required in D to simulate N is
log2
2(m)  which is also O( p2(n) )
PS and NPS
 The space bound of complexity O( p2(n) ) is
polynomial iff p(n) is polynomial
 p(n) is polynomial
 Then there is a polynomial space bound
DTM that corresponds to a polynomial space
bound NDTM
PS and NPS
 So, after all:
PS = NPS
PS and NPS
At the End, we conclude that:
PS and NPS

More Related Content

Similar to P, NP, PS, and NPS Complexity Classes Explained

2009 CSBB LAB 新生訓練
2009 CSBB LAB 新生訓練2009 CSBB LAB 新生訓練
2009 CSBB LAB 新生訓練Abner Huang
 
9. chapter 8 np hard and np complete problems
9. chapter 8   np hard and np complete problems9. chapter 8   np hard and np complete problems
9. chapter 8 np hard and np complete problemsJyotsna Suryadevara
 
Fractal Dimension of Space-time Diagrams and the Runtime Complexity of Small ...
Fractal Dimension of Space-time Diagrams and the Runtime Complexity of Small ...Fractal Dimension of Space-time Diagrams and the Runtime Complexity of Small ...
Fractal Dimension of Space-time Diagrams and the Runtime Complexity of Small ...Hector Zenil
 
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
 
Basic_concepts_NP_Hard_NP_Complete.pdf
Basic_concepts_NP_Hard_NP_Complete.pdfBasic_concepts_NP_Hard_NP_Complete.pdf
Basic_concepts_NP_Hard_NP_Complete.pdfArivukkarasu Dhanapal
 
2010 3-24 cryptography stamatiou
2010 3-24 cryptography stamatiou2010 3-24 cryptography stamatiou
2010 3-24 cryptography stamatiouvafopoulos
 
practice-final-soln.pdf
practice-final-soln.pdfpractice-final-soln.pdf
practice-final-soln.pdfT17Rockstar
 
Np completeness h4
Np completeness  h4Np completeness  h4
Np completeness h4Rajendran
 
01 - DAA - PPT.pptx
01 - DAA - PPT.pptx01 - DAA - PPT.pptx
01 - DAA - PPT.pptxKokilaK25
 
Algorithm chapter 10
Algorithm chapter 10Algorithm chapter 10
Algorithm chapter 10chidabdu
 
Marcov chains and simple queue ch 1
Marcov chains and simple queue ch 1Marcov chains and simple queue ch 1
Marcov chains and simple queue ch 1Guru Nathan
 
Introducción al Análisis y diseño de algoritmos
Introducción al Análisis y diseño de algoritmosIntroducción al Análisis y diseño de algoritmos
Introducción al Análisis y diseño de algoritmosluzenith_g
 

Similar to P, NP, PS, and NPS Complexity Classes Explained (20)

2009 CSBB LAB 新生訓練
2009 CSBB LAB 新生訓練2009 CSBB LAB 新生訓練
2009 CSBB LAB 新生訓練
 
QB104545.pdf
QB104545.pdfQB104545.pdf
QB104545.pdf
 
9. chapter 8 np hard and np complete problems
9. chapter 8   np hard and np complete problems9. chapter 8   np hard and np complete problems
9. chapter 8 np hard and np complete problems
 
Fractal Dimension of Space-time Diagrams and the Runtime Complexity of Small ...
Fractal Dimension of Space-time Diagrams and the Runtime Complexity of Small ...Fractal Dimension of Space-time Diagrams and the Runtime Complexity of Small ...
Fractal Dimension of Space-time Diagrams and the Runtime Complexity of Small ...
 
Teori pnp
Teori pnpTeori pnp
Teori pnp
 
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
 
lect5-1.ppt
lect5-1.pptlect5-1.ppt
lect5-1.ppt
 
Basic_concepts_NP_Hard_NP_Complete.pdf
Basic_concepts_NP_Hard_NP_Complete.pdfBasic_concepts_NP_Hard_NP_Complete.pdf
Basic_concepts_NP_Hard_NP_Complete.pdf
 
2010 3-24 cryptography stamatiou
2010 3-24 cryptography stamatiou2010 3-24 cryptography stamatiou
2010 3-24 cryptography stamatiou
 
practice-final-soln.pdf
practice-final-soln.pdfpractice-final-soln.pdf
practice-final-soln.pdf
 
Unit 3
Unit 3Unit 3
Unit 3
 
Unit 3
Unit 3Unit 3
Unit 3
 
Np completeness h4
Np completeness  h4Np completeness  h4
Np completeness h4
 
01 - DAA - PPT.pptx
01 - DAA - PPT.pptx01 - DAA - PPT.pptx
01 - DAA - PPT.pptx
 
class23.ppt
class23.pptclass23.ppt
class23.ppt
 
Algorithm chapter 10
Algorithm chapter 10Algorithm chapter 10
Algorithm chapter 10
 
Marcov chains and simple queue ch 1
Marcov chains and simple queue ch 1Marcov chains and simple queue ch 1
Marcov chains and simple queue ch 1
 
Introducción al Análisis y diseño de algoritmos
Introducción al Análisis y diseño de algoritmosIntroducción al Análisis y diseño de algoritmos
Introducción al Análisis y diseño de algoritmos
 
Turing machine by_deep
Turing machine by_deepTuring machine by_deep
Turing machine by_deep
 
Alg1
Alg1Alg1
Alg1
 

Recently uploaded

(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfCionsystems
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 

Recently uploaded (20)

Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdf
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the ProcessExploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
 

P, NP, PS, and NPS Complexity Classes Explained

  • 1. P, NP, PS, and NPS By Muhannad Harrim
  • 2. Class P  P is the complexity class containing decision problems which can be solved by a Deterministic Turing machine (DTM) using a polynomial amount of computation time, or polynomial time.  P is often taken to be the class of computational problems which are "efficiently solvable" or "tractable“.  But P also contains problems which are intractable in practical terms; for example, some require at least n¹ºººººº operations
  • 3. Deterministic Turing machine (DTM) DTM is:  A Turing machine model (basic symbol-manipulating device which, despite its simplicity, can be adapted to simulate the logic of any computer).  Consists of a finite state control, a read/write head, and a tape made up of a two-way infinite sequence of tape squares (or cells).
  • 5. Deterministic Turing machine (DTM)  Hopcroft and Ullman define a one-tape Turing machine formula: M=(Q, Γ, b, ∑, δ, qo, F) where:  Q is a finite set of states  Γ is a finite set of the tape alphabet/symbols  b is the blank symbol (the only symbol allowed to occur on the tape infinitely often at any step during the computation) - Delimiter  Σ, a subset of Γ not including b is the set of input symbols  δ = Q x Γ  Q x Γ x {L,R} is a partial function called the transition function, where L is left shift, R is right shift.  qo is the initial state  F is the set of final or accepting states
  • 6. Deterministic Turing machine (DTM)  A DTM program M with alphabet ∑ accepts any x: x є ∑* iff M halts in the acceptance final state (qY) when applied input x.  The language LM recognized by the program M as the following: LM = { x є ∑* : M accepts x }
  • 7. Class P & DTM A formal definition for Class P with respect to DTM would be given as follows: P = { L: there is a polynomial time DTM program M for which L = LM }
  • 8. Class P & DTM Conclusion: A decision problem π belongs to P under the encoding scheme e if L(π, e) belongs to P, that is if there is a polynomial time DTM that solves π under encoding scheme e.
  • 9. Class NP The class NP is defined informally to be the class of all decision problems π which, under reasonable encoding schemes, can be solved “verified” by polynomial time using Non-Deterministic Turing machines (NDTM). - Polynomial time verifiability doesn’t imply polynomial time solvability.
  • 10. Nondeterministic Turing machine (NDTM) NDTM model has exactly the same structure of DTM except it’s featured with a guessing module that has its own write only head. The guessing module’s main purpose is providing the means for writing down the “guess” into the tape.
  • 12. Nondeterministic Turing machine (NDTM) NDTM is also specified exactly the same way as DTM with respect to tape alphabet, input alphabet, blank symbol, states set, initial and final states, and the transition function. However, It differs from DTM in the computation process, where in NDTM it takes two stages: the guessing and the checking.
  • 13. Nondeterministic Turing machine (NDTM) If NDTM program stops at a qY then, then the computation is considered as an accepting computation. Otherwise, All other computations (halting or not) are considered to be a non-accepting computation.
  • 14. Nondeterministic Turing machine (NDTM) Also, a NDTM will have an infinite number of possible computations for a given input string x. NDTM accepts x iff at least one of the possible structures (computations) is an accepting one. LM = { x є ∑* : M accepts x }
  • 15. Class NP and NDTM A formal definition for Class NP in respect to NDTM : NP = { L : there is a polynomial time NDTM program M for which LM = L }
  • 16. Class NP and NDTM Conclusion : A decision problem π belongs to NP under the encoding scheme e if L(π, e) belongs to NP, that is if there is a polynomial time NDTM that “solves” (verifies) π under encoding scheme e.
  • 17. Class P and Class NP
  • 18. Class P and Class NP A controversial question: Is P = NP ?
  • 19. Polynomial Space (PS)  The emphasis on the computation resources is usually on the time used to perform the computation process (especially when measuring a performance issue or complexity).  However, the amount of space required is often just as important ( called the space requirement ).
  • 20. Polynomial Space (PS) In any Turing machine: – the time used is the number of steps taken before halting or entering a final state. – The space required is defined as the number of distinct tape squares (cells) “visited” by the read/write head.
  • 21. Polynomial Space (PS) Proof Since the time taken to visit all cells < = the time used, then the number of cells visited < = the time used.  the number of cells visited cannot be more than the steps of computation This implies: Any Polynomial Solvable in polynomial time, It’s solvable in polynomial space.
  • 22. Polynomial Space (PS) Although all problems solvable in polynomial time can be solved in polynomial space, it is still a controversial and unresolved question whether there exist problems solvable in polynomial space which cannot be solved in polynomial time. - This is so difficult to conclude since all problems in NP, including P and NP-C problems are solved in both polynomial space and polynomial time.
  • 23. Polynomial Space (PS)  PS is the class of all languages recognizable by polynomial space bounded DTM that halts on all inputs. i.e. All and Only the languages that are LM for some polynomial space bounded DTM M.
  • 24. Nondeterministic Polynomial Space (NPS)  NPS is the class of all languages recognizable by polynomial space bounded NDTM that halts on at least one of the possible input structures. i.e. All and Only the languages that are LM for some polynomial space bounded NDTM M.
  • 25. PS and NPS Evidently, PS є NPS, since every DTM is technically NDTM. However, The surprising result is that: PS = NPS
  • 26. PS and NPS Theorem If M is a polynomial-space bounded TM (deterministic or nondeterministic), and p(n) is its polynomial space bound, then there is a constant c such that if M accepts its input w of length n, it does so within c1 + p(n) moves
  • 27. PS and NPS Proof The essential idea is that M must repeat an ID (cell index) before making more than c1 + p(n) moves Having a constant c implies that there is a limited number of ID’s if already there is a limited space used in the TM. Let t be the number of tape symbols of M Let s be the number of states of M Then the number of different ID’s of M when only p(n) tape cells are visited is at most s x p(n) x t p(n)
  • 28. PS and NPS if c = t + s, then the binomial expansion of (t + s)1 + p(n) is t1+ p(n) + (1 + p(n)) s t p(n) + … In the expression, notice that the underlined term is at least as large as s p(n) t p(n) This proves that c1 + p(n) is at least equal to the number of possible ID’s of M
  • 29. PS and NPS M accepts w of length n with sequence of moves that doesn’t repeat any ID So  M accepts inputs by a sequence of moves that is less or equal to the number of distinct ID’s, which is c1 + p(n)
  • 30. PS and NPS Savitch’s Theorem PS = NPS
  • 31. PS and NPS To be more accurate Savitch’s Theorem states that any p(n)-space NDTM can be converted to a p2(n)-space DTM one of the earliest results on space complexity
  • 32. PS and NPS Proof The core of the proof lies on simulating a NDTM that has a polynomial space bound p(n) into a DTM with polynomial space bound of complexity O( p2(n) )
  • 33. PS and NPS This is done through a recursive program that tries to test whether a NDTM N can move from ID I to ID J in at most m moves Let’s have a function called reach(I, J, m) that decides if I can yield to J in m moves
  • 36. PS and NPS Assumptions – If NDTM N accepts, it does it within c1 + p(n) steps – Given input w of length n – DTM D discovers what N does with input w by calling the function reach(I0,J,m) recursively where:  I0 is the initial ID of N with input w  J is any accepting ID that uses at most p(n) tape cells  m = c1 + p(n)
  • 37. PS and NPS the recursive function imposes that there will never be more than log2 m recursive calls that are active simultaneously i.e one with m/2, one with m/4, … , down to 1  So, the upper bound of the number of stack frames is no more than log2(m) on the stack  log2(m) is O( p(n) )
  • 38. PS and NPS  So, D contains at most log2(m) stack frames = (O( pn ))  The stack frames themselves require log2(m) space, the reason is that the two ID’s each require only 1+p(n) cells to write down m, and m in binary requires log2 c1 + p(n)  log2(m) = (O( pn ))  The total space required in D to simulate N is log2 2(m)  which is also O( p2(n) )
  • 39. PS and NPS  The space bound of complexity O( p2(n) ) is polynomial iff p(n) is polynomial  p(n) is polynomial  Then there is a polynomial space bound DTM that corresponds to a polynomial space bound NDTM
  • 40. PS and NPS  So, after all: PS = NPS
  • 41. PS and NPS At the End, we conclude that: