2
$\begingroup$

On wikipedia's article on Polynomial-time reduction it states:

Every nontrivial decision problem in P (the class of polynomial-time decision problems, where nontrivial means that not every input has the same output) may be reduced to every other nontrivial decision problem, by a polynomial-time many-one reduction. To transform an instance of problem A to B, solve A in polynomial time, and then use the solution to choose one of two instances of problem B with different answers

Some looking into the history of this entry reveals a link to math.SE that was referenced as a proof at one time.

However I am still confused as to exactly how this works. I understand polynomial-time reductions but there are some specific questions I have in regards to this statement.

  1. Is it required that A is non-trivial as stated on wikipedia? Some places seem to suggest that the requirement is only B has to be non-trivial, and A doesn't matter if trivial or non-trivial. Based on this question.

  2. Can someone provide me a concrete example of this working. I don't quite understand how there are two instances of problem B with different answers and how it relies on problem A to choose

$\endgroup$
  • $\begingroup$ How does this not answer your question? $\endgroup$ – Raphael Dec 7 '14 at 11:14
3
$\begingroup$

First, it's important to realize here that the output of a decision problem will always be "Yes" or "No." So what this is saying is basically that $B$ has at least two inputs $x,y$ where $x \in L_B$ and $y \not \in L_B$, if $L_B$ is the set (language) of all accepted inputs to $B$.

Let's let $B$ be SAT. We'll take two instances, $x = v_1 \vee \neg v_1$, which has a solution and thus is in SAT, and $y = v_1 \wedge \neg v_1$.

Let's let $A$ be the undirected graph-connectivity problem. We know that we can solve this in polynomial time using Breadth First Search.

So, given a graph $G$ as input to $A$, we'll define a function $f$:

$f(G) = x$ if $BFS(G)$ returns connected

$f(G) = y$ if $BFS(G)$ returns not connected

Clearly, we can compute $f(G)$ in linear time for any graph, since it's just a breadth-first search. Moreover, we see that $G$ is connected if and only if $f(G) \in SAT$.

The whole process is kind of trivial (in the mathematical sense), because we're basically saying "If we could solve $B$ in polynomial time, we could also solve $A$ in polynomial time". But we can always solve $A$ in polynomial time, so the whole thing is trivially true.

It holds for the same reason $P \implies \top$ is always true.

$\endgroup$
1
$\begingroup$

A reduction maps the yes-instances of problem $A$ to yes-instances of problem $B$ and the no-instances of problem $A$ to no-instances of problem $B$. In other words the mapping $f$ is a reduction if and only if $x \in A \Leftrightarrow f(x) \in B$ for all strings $x$.

Let $A$ be any language in $\mathbf{P}$ and $B$ be the finite language that contains only the string "1". We can simply map every string $s \in A$ to "1", and every string $s \not\in A$ to "0". Since $A$ is in $\mathbf{P}$, we can do this in polynomial time by using a polynomial time algorithm to decide whether a string is in $A$, and then output "1" or "0" accordingly.

In general, if $A$ has yes-instances, then $B$ must also have yes-instances. If $A$ has no-instances, then $B$ must also have no-instances. Therefore a reduction is always possible if $B$ is non-trivial, which just means that $B$ has both no- and yes-instances. If $B$ is trivial, then $A$ must also be trivial. Say $B$ is the trivial language that contains all strings. Then $A$ must not have no-instances, because they cannot be mapped anywhere, because $B$ has only yes-instances.

$\endgroup$
  • $\begingroup$ The way you worded this is what got me confused in the first place. If A is trivial and B is nontrivial, then it won't work, right? You seem to only mention that B has to be non-trivial $\endgroup$ – ParoX Dec 7 '14 at 10:02
  • $\begingroup$ Thinking about this more, I think A can be trivial, because if A is just saying "no" then B will just say "no" and if A is just saying "yes" then B will just say "yes". Correct? $\endgroup$ – ParoX Dec 7 '14 at 10:18
  • $\begingroup$ Yes, that is correct. $\endgroup$ – jnalanko Dec 7 '14 at 10:55
1
$\begingroup$

Now that I think I understand it more, I will provide my own understanding of the question for archive purposes in case someone in the future finds this post and is equally as confused as I was and may benefit from the mathematical laymen perspective.

Given A is in P, and the reduction itself is just a way of saying that you can solve A by using B in polynomial time. The reduction is a bit of a cheat, the way it lets B solve A is by first solving A and then uses B as a middle man to relay the solution.

As long as B has some input that says its false, and some input that says its true (B is non-trivial) then B can act as a middle man.

The process involves first solving A, which can be done in polynomial time since it is in P. Then you will input into B whatever corresponds to the output A had. If A's decision was TRUE, you will send whatever input makes B true, so that it relays TRUE. If A's decision is FALSE you will send whatever input makes B false so it relays FALSE. This way you are using B as a way to find a solution that works for A (Although in reality you are using A to solve A)

$\endgroup$
  • $\begingroup$ Make sure to upvote answers you liked. $\endgroup$ – Raphael Dec 7 '14 at 11:15

Not the answer you're looking for? Browse other questions tagged or ask your own question.