# How to do a Reduction

## (No, we’re not making sauce)

Suppose we have a problem ** A** that we want to solve. If we can find a way to turn

**into some other problem**

*A*

*B**that we know how to solve, then our solution for*

**involves:**

*A*- Transforming problem
*A**B* - Solving
*B* - Transforming
’s solution to*B*’s solution*A*

This whole process is itself an algorithm, and it’s called reduction.

Reduction is useful for solving problems that are similar because you can re-use algorithms, but also because it tells us something about the relative difficulty of problems. If we can easily transform an ** A **problem into a

**problem, then we know that if we can solve**

*B***, we can easily solve**

*B***, and thus**

*A***is at least as hard as**

*B***.**

*A*“Hard” in this sense refers to computational resources: time and space complexity, etc.

#### Notation

In computer science, we represent the ** A **to

**reduction with**

*B***.**

*A ≤ B*Sometimes we also subscript ≤ with the type of the reduction (** p **for polynomial reduction, for example, meaning that the reduction to and from

**— the 1st and 3rd boxes — can be done in polynomial time).**

*B*#### Proving a reduction correct

We should be able to verify that this algorithm for solving ** A** is correct. We must assume that our solution for

**is correct (don’t reduce one problem you don’t know how to solve into another problem you don’t know how to solve), so then we just have to show that the work we do reducing to and from**

*B***is correct.**

*B*We want to prove that a correct solution to ** B **gives a correct solution to

**A**

*.*(Why not the other direction? Let’s think about it — showing

**is correct =>**

*A***is correct doesn’t help our case at all, because we’d be assuming what we’re trying to prove is already correct.)**

*B*If that’s too hard (it’s often hard to prove things correct), we can try to prove the contrapositive instead: ~** A => ~B**. That is, if the solution to

**is false then the solution to**

*A***is also false.**

*B*And that’s it! Isn’t it awesome that we’ve formalized being lazy??!