complexity. p=np? who knows? who cares? lets revisit some questions from last time – how many...
TRANSCRIPT
![Page 1: Complexity. P=NP? Who knows? Who cares? Lets revisit some questions from last time – How many pairwise comparisons do I need to do to check if a sequence](https://reader035.vdocuments.us/reader035/viewer/2022062619/5517a68f55034645368b5c93/html5/thumbnails/1.jpg)
“Complexity”
![Page 2: Complexity. P=NP? Who knows? Who cares? Lets revisit some questions from last time – How many pairwise comparisons do I need to do to check if a sequence](https://reader035.vdocuments.us/reader035/viewer/2022062619/5517a68f55034645368b5c93/html5/thumbnails/2.jpg)
P=NP? Who knows? Who cares?
• Let’s revisit some questions from last time– How many pairwise comparisons do I
need to do to check if a sequence of n-numbers is sorted?
– If I have a procedure for checking whether a sequence is sorted, is it reasonable to sort a sequence of numbers by generating permutations and testing if any of them are sorted?
– What major CS theorem did someone claimed to have proved recently?
Intelligence is putting the “test” part of Generate&Test into generate part…
![Page 3: Complexity. P=NP? Who knows? Who cares? Lets revisit some questions from last time – How many pairwise comparisons do I need to do to check if a sequence](https://reader035.vdocuments.us/reader035/viewer/2022062619/5517a68f55034645368b5c93/html5/thumbnails/3.jpg)
Exactly when do we say an algorithm is “slow”?
• We kind of felt that O(N! * N) is a bit much complexity
• How about O(N2)? O(N10)? Where do we draw the line?– Meet the Computer Scientist Nightmare– So “Polynomial” ~ “easy” & “exponential” ~ “hard”– 2n eventually overtakes any nk however large k is..
• How do we know if a problem is “really” hard to solve or it is just that I am dumb and didn’t know how to do better?
2n
![Page 4: Complexity. P=NP? Who knows? Who cares? Lets revisit some questions from last time – How many pairwise comparisons do I need to do to check if a sequence](https://reader035.vdocuments.us/reader035/viewer/2022062619/5517a68f55034645368b5c93/html5/thumbnails/4.jpg)
Classes P and NP
Class P• If a problem can be solved
in time polynomial in the size of the input it is considered an “easy” problem– Note that your failure to solve
a problem in polynomial time doesn’t mean it is not polynomial (you could come up with O(N* N!) algorithm for sorting, after all
Class NP• Technically “if a problem can
be solved in polynomial time by a non-deterministic turing machine, then it is in class NP”
• Informally, if you can check the correctness of a solution in polynomial time, then it is in class NP– Are there problems where even
checking the solution is hard?
![Page 5: Complexity. P=NP? Who knows? Who cares? Lets revisit some questions from last time – How many pairwise comparisons do I need to do to check if a sequence](https://reader035.vdocuments.us/reader035/viewer/2022062619/5517a68f55034645368b5c93/html5/thumbnails/5.jpg)
Tower of Hanoi (or Brahma)• Shift the disks from the left
peg to the right peg– You can lift one disk at a time – You can use the middle peg to
“park” disks– You can never ever have a
larger disk on top of a smaller disk (or KABOOM)
• How many moves to solve a 2-disk version? A 3-disk one? An n-disk one?– How long does it take (in
terms of input size), to check if you have a correct solution?
![Page 6: Complexity. P=NP? Who knows? Who cares? Lets revisit some questions from last time – How many pairwise comparisons do I need to do to check if a sequence](https://reader035.vdocuments.us/reader035/viewer/2022062619/5517a68f55034645368b5c93/html5/thumbnails/6.jpg)
How to explain to your boss as to why your program is so slow…
I can't find an efficient algorithm, I guess I'm just too dumb.
I can't find an efficient algorithm, because no such algorithm is possible.
I can't find an efficient algorithm, but neither can all these famous people.
![Page 7: Complexity. P=NP? Who knows? Who cares? Lets revisit some questions from last time – How many pairwise comparisons do I need to do to check if a sequence](https://reader035.vdocuments.us/reader035/viewer/2022062619/5517a68f55034645368b5c93/html5/thumbnails/7.jpg)
The P=NP question• Clearly, all polynomial problems are
also NP problems• Do we know for sure that there are
NP problems that are not polynomial?
• If we assume this, then we are assuming P != NP
• If P = NP, then some smarter person can still solve a problem that we thought can’t be solved in polytime– Can imply more than a loss of face…
For example, factorization is known to be an NP-Complete problem; and forms the basis for all of cryptography.. If P=NP, then all the cryptography standards can be broken!
NP-Complete: “hardest” problems in class NP
EVERY problem in class NP can be reduced to an NP-Complete problem in polynomial time --So you can solve that problem by using an algorithm that solves the NP-complete problem
![Page 8: Complexity. P=NP? Who knows? Who cares? Lets revisit some questions from last time – How many pairwise comparisons do I need to do to check if a sequence](https://reader035.vdocuments.us/reader035/viewer/2022062619/5517a68f55034645368b5c93/html5/thumbnails/8.jpg)
Academic Integrity
• What it means• Typical ASU policy– Homeworks– Exams• Take-Home Exams
– Term papers
![Page 9: Complexity. P=NP? Who knows? Who cares? Lets revisit some questions from last time – How many pairwise comparisons do I need to do to check if a sequence](https://reader035.vdocuments.us/reader035/viewer/2022062619/5517a68f55034645368b5c93/html5/thumbnails/9.jpg)
Scholarship Opportunities
• General Scholarships• The FURI program• NSF REU program
![Page 10: Complexity. P=NP? Who knows? Who cares? Lets revisit some questions from last time – How many pairwise comparisons do I need to do to check if a sequence](https://reader035.vdocuments.us/reader035/viewer/2022062619/5517a68f55034645368b5c93/html5/thumbnails/10.jpg)
Is exponential complexity the worst?
• After all, we can have 22
More fundamental question:Can every computational
problem be solved in finite time?
“Decidability” --Unfortunately not
guaranteed [and Hilbert turns in his grave]
2n
![Page 11: Complexity. P=NP? Who knows? Who cares? Lets revisit some questions from last time – How many pairwise comparisons do I need to do to check if a sequence](https://reader035.vdocuments.us/reader035/viewer/2022062619/5517a68f55034645368b5c93/html5/thumbnails/11.jpg)
Some Decidability Challenges
• In First Order Logic, inference (proving theorems) is semi-decidable – If the theorem is true, you can show
that in finite time; if it is false you may never be able to show it
• In First Order Logic + Peano Arithmatic, inference is undecidable– There may be theorems that are true
but you can’t prove them [Godel]
![Page 12: Complexity. P=NP? Who knows? Who cares? Lets revisit some questions from last time – How many pairwise comparisons do I need to do to check if a sequence](https://reader035.vdocuments.us/reader035/viewer/2022062619/5517a68f55034645368b5c93/html5/thumbnails/12.jpg)
Reducing Problems…
Mathematician reduces “mattress on fire” problem
Make Rao Happy
Make Everyone in ASU Happy Make Little
Tommy Happy
Make his entire family happy
General NP-problem
Boolean Satisfiability
Problem
3-SAT
![Page 13: Complexity. P=NP? Who knows? Who cares? Lets revisit some questions from last time – How many pairwise comparisons do I need to do to check if a sequence](https://reader035.vdocuments.us/reader035/viewer/2022062619/5517a68f55034645368b5c93/html5/thumbnails/13.jpg)
Practical Implications of Intractability
• A class of problems is said to be NP-hard as long as the class contains at least one instance that will take exponential time..
• What if 99% of the instances are actually easy to solved?--Where then are the wild things?
![Page 14: Complexity. P=NP? Who knows? Who cares? Lets revisit some questions from last time – How many pairwise comparisons do I need to do to check if a sequence](https://reader035.vdocuments.us/reader035/viewer/2022062619/5517a68f55034645368b5c93/html5/thumbnails/14.jpg)
Satisfiability problem
• Given a set of propositions P1 P2 … Pn • ..and a set of “clauses” that the propositions must satisfy
– Clauses are of the form P1 V P7 VP9 V P12 V ~P35
– Size of a clause is the number of propositions it mentions; size can be anywhere from 1 to n
• Find a T/F assignment to the propositions that respects all clauses
• Is it in class NP? How many “potential” solutions?
Canonical NP-Complete Problem.• 3-SAT is where all clauses are of length 3
![Page 15: Complexity. P=NP? Who knows? Who cares? Lets revisit some questions from last time – How many pairwise comparisons do I need to do to check if a sequence](https://reader035.vdocuments.us/reader035/viewer/2022062619/5517a68f55034645368b5c93/html5/thumbnails/15.jpg)
Example of a SAT problem
• P,Q,R are propositions• Clauses– P V ~Q V R– Q V ~R V ~P
• Is P=False, Q=True, R=False as solution?• Is Boolean SAT in NP?
![Page 16: Complexity. P=NP? Who knows? Who cares? Lets revisit some questions from last time – How many pairwise comparisons do I need to do to check if a sequence](https://reader035.vdocuments.us/reader035/viewer/2022062619/5517a68f55034645368b5c93/html5/thumbnails/16.jpg)
Hardness of 3-sat as a function of #clauses/#variables
#clauses/#variables
Probability that there is a satisfying assignment
Cost of solving (either by finding a solution or showing there ain’t one)
p=0.5You would expect this
This is what happens!
~4.3Phase Transition!
![Page 17: Complexity. P=NP? Who knows? Who cares? Lets revisit some questions from last time – How many pairwise comparisons do I need to do to check if a sequence](https://reader035.vdocuments.us/reader035/viewer/2022062619/5517a68f55034645368b5c93/html5/thumbnails/17.jpg)
Phase Transition in SAT
Theoretically we only know that phase transition ratio occurs between 3.26 and 4.596.
Experimentally, it seems to be close to 4.3(We also have a proof that 3-SAT has sharp threshold)