# Function problem

> Mediated Wiki article. Canonical URL: https://mediated.wiki/source/Function_problem
> Markdown URL: https://mediated.wiki/source/Function_problem.md
> Source: https://en.wikipedia.org/wiki/Function_problem
> Source revision: 1326585305
> License: Creative Commons Attribution-ShareAlike 4.0 International (https://creativecommons.org/licenses/by-sa/4.0/)

Type of computational problem

In [computational complexity theory](/source/Computational_complexity_theory), a **function problem** is a [computational problem](/source/Computational_problem) where a single output is expected for every input, but the output is more complex than that of a [decision problem](/source/Decision_problem). For function problems, the output is not simply 'yes' or 'no'.

## Definition

A *function problem* P {\displaystyle P} is defined by a [relation](/source/Relation_(mathematics)) R {\displaystyle R} over [strings](/source/String_(computer_science)) of an arbitrary [alphabet](/source/Alphabet_(computer_science)) Σ {\displaystyle \Sigma } :

- R ⊆ Σ ∗ × Σ ∗ . {\displaystyle R\subseteq \Sigma ^{*}\times \Sigma ^{*}.}

Note that R {\displaystyle R} does not have to be a [functional](/source/Binary_relation#Types_of_binary_relations) binary relation.

An [algorithm](/source/Algorithm) solves P {\displaystyle P} if for every input x {\displaystyle x} such that there exists a y {\displaystyle y} satisfying ( x , y ) ∈ R {\displaystyle (x,y)\in R} , the algorithm produces one such y {\displaystyle y} , and if there are no such y {\displaystyle y} , it rejects.

A *promise function problem* permits the algorithm to do anything (thus may not terminate) if no such y {\displaystyle y} exists.

## Examples

A well-known function problem is given by the functional Boolean satisfiability problem, **FSAT** for short. The problem, which is closely related to the [**SAT**](/source/Boolean_satisfiability_problem) decision problem, can be formulated as follows:

- Given a [propositional formula](/source/Propositional_formula) φ {\displaystyle \varphi } with variables x 1 , … , x n {\displaystyle x_{1},\ldots ,x_{n}} , find an assignment x i → { TRUE , FALSE } {\displaystyle x_{i}\rightarrow \{{\text{TRUE}},{\text{FALSE}}\}} such that φ {\displaystyle \varphi } evaluates to TRUE {\displaystyle {\text{TRUE}}} or decide that no such assignment exists.

In this case the relation R {\displaystyle R} is given by pairs of suitably encoded propositional formulas and satisfying assignments. While a SAT algorithm, fed with a formula φ {\displaystyle \varphi } , only needs to return "unsatisfiable" or "satisfiable", an FSAT algorithm needs to return some satisfying assignment in the latter case.

Other notable examples include the [travelling salesman problem](/source/Travelling_salesman_problem), which asks for the route taken by the salesman, and the [integer factorization problem](/source/Integer_factorization_problem), which asks for the list of factors.

## Relationship to other complexity classes

Consider an arbitrary [decision problem](/source/Decision_problem) L {\displaystyle L} in the class [**NP**](/source/NP_(complexity)). By the definition of **NP**, there is a system of certificates such that each problem instance x {\displaystyle x} that is answered 'yes' has a [polynomial](/source/Polynomial)-size certificate y {\displaystyle y} that serves as a proof for the 'yes' answer (and problem instances answered 'no' have no such certificates). Thus, the set of these pairs ( x , y ) {\displaystyle (x,y)} forms a relation, representing the function problem "given x {\displaystyle x} in L {\displaystyle L} , find a certificate y {\displaystyle y} for x {\displaystyle x} ". This function problem is called a *function variant* of L {\displaystyle L} ; it belongs to the class **[FNP](/source/FNP_(complexity))**.

Conversely, every problem *R* in **FNP** induces a (unique) corresponding decision problem: given *x*, decide if there exists some *y* such that *R*(*x*,*y*) holds.

**FNP** can be thought of as the function class analogue of **NP**, in that solutions of **FNP** problems can be efficiently (i.e., in [polynomial time](/source/Polynomial_time) in terms of the length of the input) *verified*, but not necessarily efficiently *found*. In contrast, the class **[FP](/source/FP_(complexity))**, which can be thought of as the function class analogue of **P**, consists of function problems for which solutions can be found in polynomial time.

## Self-reducibility

Observe that the problem **FSAT** introduced above can be solved using only polynomially many calls to a subroutine that decides the **SAT** problem: An algorithm can first ask whether the formula φ {\displaystyle \varphi } is satisfiable. After that the algorithm can fix variable x 1 {\displaystyle x_{1}} to TRUE and ask again. If the resulting formula is still satisfiable the algorithm keeps x 1 {\displaystyle x_{1}} fixed to TRUE and continues to fix x 2 {\displaystyle x_{2}} , otherwise it decides that x 1 {\displaystyle x_{1}} has to be FALSE and continues. Thus, **FSAT** is solvable in polynomial time using an [oracle](/source/Oracle_machine) deciding **SAT**. In general, a problem in **FNP** is called *self-reducible* if it can be solved in polynomial time using an oracle for its induced decision problem. Every function variant of every **[NP-complete](/source/NP-complete)** problem is self-reducible. There are several (slightly different) notions of self-reducibility.[1][2][3]

## Reductions and complete problems

Function problems can be [reduced](/source/Reduction_(complexity)) much like decision problems: Given function problems R {\displaystyle R} and S {\displaystyle S} we say that R {\displaystyle R} reduces to S {\displaystyle S} if there exist polynomially-time computable functions f {\displaystyle f} and g {\displaystyle g} such that for all instances x {\displaystyle x} of R {\displaystyle R} and possible solutions y {\displaystyle y} of S {\displaystyle S} , it holds that

- If x {\displaystyle x} has an R {\displaystyle R} -solution, then f ( x ) {\displaystyle f(x)} has an S {\displaystyle S} -solution.

- ( f ( x ) , y ) ∈ S ⟹ ( x , g ( x , y ) ) ∈ R . {\displaystyle (f(x),y)\in S\implies (x,g(x,y))\in R.}

It is therefore possible to define *FNP-hard* problems analogous to NP-hard problems:

A problem R {\displaystyle R} is **FNP-hard** if every problem in **FNP** can be reduced to R {\displaystyle R} . A problem R {\displaystyle R} is **FNP-complete** if it is FNP-hard and in **FNP**. The problem **FSAT** is an FNP-complete problem, and hence by self-reducibility of **FSAT** it holds that P = N P {\displaystyle \mathbf {P} =\mathbf {NP} } if and only if F P = F N P {\displaystyle \mathbf {FP} =\mathbf {FNP} } .

## Total function problems

The relation R ( x , y ) {\displaystyle R(x,y)} used to define function problems has the drawback of being possibly incomplete: Not every input x {\displaystyle x} necessarily has a counterpart y {\displaystyle y} such that ( x , y ) ∈ R {\displaystyle (x,y)\in R} . Therefore the question of computability of outputs is not separated from the question of their existence. To overcome this problem it is convenient to consider the restriction of function problems to total relations yielding the class **[TFNP](/source/TFNP)** as a subclass of **FNP**. This class contains problems such as the computation of pure [Nash equilibria](/source/Nash_equilibria) in certain strategic games where a solution is guaranteed to exist. In addition, if **TFNP** contains any **FNP-complete** problem it follows that N P = co-NP {\displaystyle \mathbf {NP} ={\textbf {co-NP}}} .

## See also

- [Decision problem](/source/Decision_problem)

- [Search problem](/source/Search_problem)

- [Counting problem (complexity)](/source/Counting_problem_(complexity))

- [Optimization problem](/source/Optimization_problem)

## References

1. **[^](#cite_ref-1)** Ko, K. (1983). "On self-reducibility and weak P-selectivity". *[Journal of Computer and System Sciences](/source/Journal_of_Computer_and_System_Sciences)*. **26** (2): 209–221. [doi](/source/Doi_(identifier)):[10.1016/0022-0000(83)90013-2](https://doi.org/10.1016%2F0022-0000%2883%2990013-2).

1. **[^](#cite_ref-2)** [Schnorr, C.](/source/Claus_P._Schnorr) (1976). "Optimal algorithms for self-reducible problems". *In S. Michaelson and R. Milner, Editors, Proceedings of the 3rd [International Colloquium on Automata, Languages, and Programming](/source/International_Colloquium_on_Automata%2C_Languages%2C_and_Programming)*: 322–337.

1. **[^](#cite_ref-3)** Selman, A. (1988). "Natural self-reducible sets". *[SIAM Journal on Computing](/source/SIAM_Journal_on_Computing)*. **17** (5): 989–996. [doi](/source/Doi_(identifier)):[10.1137/0217062](https://doi.org/10.1137%2F0217062).

This article includes a list of general references, but it lacks sufficient corresponding inline citations. Please help to improve this article by introducing more precise citations. (October 2015) (Learn how and when to remove this message)

- Raymond Greenlaw, H. James Hoover, *Fundamentals of the theory of computation: principles and practice*, Morgan Kaufmann, 1998, [ISBN](/source/ISBN_(identifier)) [1-55860-474-X](https://en.wikipedia.org/wiki/Special:BookSources/1-55860-474-X), p. 45-51

- [Elaine Rich](/source/Elaine_Rich), *Automata, computability and complexity: theory and applications*, Prentice Hall, 2008, [ISBN](/source/ISBN_(identifier)) [0-13-228806-0](https://en.wikipedia.org/wiki/Special:BookSources/0-13-228806-0), section 28.10 "The problem classes FP and FNP", pp. 689–694

---
Adapted from the Wikipedia article [Function problem](https://en.wikipedia.org/wiki/Function_problem) by Wikipedia contributors ([contributor history](https://en.wikipedia.org/wiki/Function_problem?action=history)). Available under [Creative Commons Attribution-ShareAlike 4.0 International](https://creativecommons.org/licenses/by-sa/4.0/). Changes may have been made.
