|
| 1 | +--- |
| 2 | +tags: |
| 3 | + - OMSCS |
| 4 | + - Algorithms |
| 5 | +--- |
| 6 | +# 06.1 - NP - Theory Guidance |
| 7 | +> NP-Complete reductions are proofs, and as such we require you to include specific content. This post outlines those expectations. |
| 8 | +
|
| 9 | +## Context |
| 10 | +We have some unknown problem B, and we want to show that it is **NP-Complete**. To accomplish this we must do the following. |
| 11 | + |
| 12 | +First, we demonstrate that problem B is in the class of NP problems. We are given a candidate solution to an instance of our unknown problem B, and we show that we can validate that solution in Polynomial time. We are not solving the problem, we are checking that the candidate solution is in fact a complete and valid solution. |
| 13 | + |
| 14 | +Formally, if given an instance $I$ and solution $S$, we can verify $S$ is a solution to $I$ in polynomial time with respect to the size of $I$. Be extra careful if there is a goal ($g$), target ($k$), or budget ($b$) given. Do not make your runtime dependent on this value or you will end up with a pseudo-polynomial verification algorithm. |
| 15 | + |
| 16 | +Next, we demonstrate that problem B is at least as hard as a problem known to be NP-Complete. This is done via reduction from a known problem A ($A \rightarrow B$), as covered in Chapter 8 of the text. |
| 17 | + |
| 18 | +![[Pasted image 20260323202556.png]] |
| 19 | + |
| 20 | +These specific steps are as follows. |
| 21 | +### Input Transformation |
| 22 | +Show how any instance $I$ of problem A is converted to an instance of problem B. This is the function $f$ which yields the input $f(I)$ to Problem B. Function $f$ must have polynomial time complexity. |
| 23 | +### Output Transformation |
| 24 | +Show how a solution $S$ to problem B is converted to a solution for problem A. This is the function $h$, which yields the solution $h(S)$ for Problem A. Function $h$ must have polynomial time complexity. You must detail this step, even if the output from B provides a solution to A without transformation. |
| 25 | +### Correctness Proof |
| 26 | +Show that a solution for B exists iff a solution to A exists. You must prove both directions. If you have a solution to instance $f(I)$ for B, you have a solution to instance $I$ of A. If there is no solution for B, then no solution exists for A. |
| 27 | + |
| 28 | +This is where we explain why our reduction works. What is it about the input and output transformations which guarantee that the unknown problem is solved only if the known problem is solved, and that a solution to the unknown problem guarantees a solution to the known problem? |
| 29 | + |
| 30 | +## Format for you Reduction |
| 31 | +While there is no required format for the reduction, the following outline is a best practice which should ensure that your proof covers all the required information. |
| 32 | + |
| 33 | +The first section (typically a single paragraph) should cover Step 1, demonstrating that B is in the class NP. You should detail in words and at a high level the steps required to confirm that the candidate solution is valid, i.e. that it solves the problem. You must provide analysis in Big O notation of the steps involved. Any polynomial-time approach is sufficient. We are not looking for a particularly efficient way to validate the candidate, as long as it's within the $O(n^p)$ class of solutions. |
| 34 | + |
| 35 | +The second section demonstrates the reduction $A \rightarrow B$. Each step is described in narrative form. A runtime analysis of the input and output transformation is required and should be presented and summarized in Big O notation. Again, any polynomial-time approach is acceptable. The demonstration if $B \iff A$ comes last, and is best presented as it's own paragraph. |
| 36 | + |
| 37 | +As an example to guide your, a written proof of NP3: 3SAT is included in this repository: [[3SAT is NP.pdf]] |
| 38 | + |
| 39 | +## Demonstrating if-and-only-if (IFF) |
| 40 | +In formal logic, when we prove "A if and only if B" or "A IFF B" or $A \iff B$, we are working with the logical AND of 2 implications: $A \iff B = (A \rightarrow B) \wedge (B \rightarrow A)$ "A iff B = (if A then B) AND (if B then A)" |
| 41 | + |
| 42 | +In NP-C we have to prove "B has a solution iff A has a solution," so we have to prove our 2 implications. |
| 43 | + |
| 44 | +- If B has a solution then A has a solution |
| 45 | +- If A has a solution then B has a solution |
| 46 | + |
| 47 | +This is where the contrapositive comes into play. Maybe instead of proving $B \rightarrow A$, it would be easier to prove "If A has NO solution, then B has NO solution." Since these are contrapositives, we can interchange them. If we do this, then we will have to prove these two implications: |
| 48 | + |
| 49 | +- If A has a solution, then B has a solution |
| 50 | +- If A has NO solution, then B has NO solution |
| 51 | + |
| 52 | +Doing this is exactly the same as what we had to prove in the previous paragraph, and doing this will prove "A has a solution iff B has a solution". |
| 53 | + |
| 54 | +The issue that the course TA's see a lot is misunderstanding which things to prove. Usually this involves proving a statement and its own contrapositive, which amounts to only showing one direction of the "A iff B" biconditional. That is, doing something like proving: |
| 55 | + |
| 56 | +- if A has a solution then B has a solution |
| 57 | +- if B has NO solution then A has NO solution |
| 58 | + |
| 59 | +These are logically equivalent statements, and therefore we've demonstrated $A \rightarrow B$ twice, and $B \rightarrow A$ 0 times. The course TA's also often see solutions of this form. |
| 60 | + |
| 61 | +- if A has a solution then B has a solution |
| 62 | +- if B has NO solution then A has NO solution |
| 63 | +- if B has a solution then A has a solution |
| 64 | +- if A has NO solution then B has NO solution |
| 65 | + |
| 66 | +This is valid and shows the whole proof, but it amounts to double the amount of work required. |
| 67 | + |
| 68 | +Below are the four allowed combinations of two implications that will prove B iff A. You can learn all four and pick the one that's easiest for the problem at hand. You can also just learn one hammer and use it for every nail. Regardless, these are the only combinations that work. |
| 69 | + |
| 70 | +1. **Double positive** |
| 71 | + - if A has a solution then B has a solution |
| 72 | + - if B has a solution then A has a solution |
| 73 | + - This one is the standard form. |
| 74 | +2. **1 Contrapositive from A** |
| 75 | + - if A has a solution then B has a solution |
| 76 | + - if A has NO solution then B has NO solution |
| 77 | +3. **1 Contrapositive from B** |
| 78 | + - if B has a solution then A has a solution |
| 79 | + - if B has NO solution then A has NO solution |
| 80 | +4. **Double Contrapositive** |
| 81 | + - if A has NO solution then B has NO solution |
| 82 | + - if B has NO solution then A has NO solution |
| 83 | + - This one is rare. |
| 84 | + |
| 85 | +Any one of these four options will provide the necessary proof of "B has a solution iff A has a solution." There is no need to perform one of these. No other legal combinations exist which provide a full proof. |
| 86 | + |
| 87 | +## General Tips and Mistakes to Avoid |
| 88 | +- Be sure to reduce **FROM** a known NP-C problem **TO** an unknown problem. Going the wrong way is an automatic -16 point penalty. |
| 89 | +- Pick a known problem which resembles the unknown problem. |
| 90 | +- If you are asked to perform a reduction from a specific problem, it **must** be used to obtain any points for the reduction portion of the submission. |
| 91 | +- You do now need to know the details of the known problem, nor the runtime. Just know the input, output, and what causes it to return `NO`. You need to map these to your unknown. |
| 92 | +- You do not need to know a solution to the unknown problem. Treat it as a black box and assume some algorithm exists that solves the problem. **Do NOT design a solution to the unknown problem.** This wastes time and will not net any points. |
| 93 | +- Make as few transformations as possible. |
| 94 | +- Algorithms and black boxes from prior sections are available for use. As with before, black boxes for graphs remain unmodifiable. |
| 95 | +- If you have to do a ton of work to change the input, you might have chosen wrong. |
| 96 | +- Be sure to include independent runtime analyses (including overall runtime) in Big-O for the NP proof, input transformation, and output transformation. You are not being assessed on the optimality of the transformation, but the correctness and completeness of your analysis and the work being completed in polynomial time. |
| 97 | +- Be sure not to depend on goals like $g$, $k$, or $b$ in your runtime. |
| 98 | +- When demonstrating "B iff A", be sure to keep the instances of the problem straight. It's an instance of B compared to an instance of A. |
| 99 | +- Do not place arbitrary limits on the instance of the known problem. Your reduction should work for **any valid instance** of A. |
| 100 | + |
| 101 | +This video is a good primer to this whole subject: https://www.youtube.com/watch?v=YX40hbAHx3s |
| 102 | + |
| 103 | +## Problems Available for Reductions |
| 104 | +We proclaim that any NP-Complete problem has a polynomial time reduction to any other NP-Complete problem. However, the transformations required to turn one into another can become quite exotic, and may require advanced techniques that would take focus away from the reduction and inth the world of transformation novelty in and of itself. |
| 105 | + |
| 106 | +For this course, we will be working with reductions of the following known problems: |
| 107 | + |
| 108 | +- SAT |
| 109 | +- 3SAT |
| 110 | +- Clique |
| 111 | +- Independent Set (IS) |
| 112 | +- Vertex Cover (VC) |
| 113 | +- Subset Sum (SSS) |
| 114 | +- Rudrata Path |
| 115 | +- Rudrata (s,t)-Path |
| 116 | +- Rudrata Cycle |
| 117 | +- Integer Linear Programming (ILP) |
| 118 | +- Zero-One Equations (ZOE) |
| 119 | +- 3D Matching |
| 120 | +- Traveling Salesman Problem (TSP) |
| 121 | + |
| 122 | +Any other problems are not eligible for reductions within the confines for this course. [Mario is NP-Hard](https://www.youtube.com/watch?v=oS8m9fSk-Wk), but nonetheless is not available for this course. Also a good read: [[Classic Nintendo Games are (Computationally) Hard.pdf]] |
| 123 | + |
| 124 | +> Dr. Vigoda goes through great lengths in the lectures to show that SAT, 3SAT, Independent Set (IS), Clique, Vertex Cover (VC), and Subset Sum (SSS) are known NP-Complete problems. |
| 125 | +> |
| 126 | +> These known problems should be considered your best starting point when beginning a new reduction. |
| 127 | +
|
0 commit comments