Documentation

CslibFrontier.Computability.Complexity.Classes.TFNP

Search problems: FNP, FP and TFNP #

A search problem is a relation R : α → List Bool → Prop between instances and solutions; the task is to find, given a, some w with R a w Papadimitriou, Section 10.3, Arora and Barak, Section 2.5. Solutions are bit strings, so the length of a solution is the length of its description, as in Megiddo and Papadimitriou [MP91]. Instances are encoded by enc : α ↪ List Bool, and a verifier reads the pair encPair enc encBits (a, w) = frame (enc a) ++ w, as for Cslib.Complexity.NP.

NP is the class of domains of FNP relations (Cslib.Complexity.mem_NP_iff_exists_FNP), and the domain of a relation in FPSearch is in P (Cslib.Complexity.searchDomain_mem_P). Hence FNP enc ⊆ FPSearch enc implies NP enc ⊆ P enc (Cslib.Complexity.NP_subset_P_of_FNP_subset_FPSearch). The converse, and the search-to-decision reduction for SAT, are in CslibFrontier.Computability.Complexity.Classes.TFNP.SearchToDecision.

Total problems arise from NP ∩ coNP: if A and its complement are domains of the FNP relations R and S, then the disjoint sum Cslib.Complexity.searchSum R S, whose solutions are true :: u for a solution u of R and false :: u for a solution u of S, is in TFNP. Solving it in polynomial time decides A, so TFNP enc ⊆ FPSearch enc implies NP enc ∩ coNP enc ⊆ P enc [MP91] (Cslib.Complexity.NP_inter_coNP_subset_P_of_TFNP_subset_FPSearch). The converse is not known, and no relation is claimed to be hard here.

Reductions #

A polynomial-time search reduction from R to S (Cslib.Complexity.SearchReducible) is a pair of polynomial-time functions: f maps instances of R to instances of S, and g maps a solution w of f a back to the solution g (a, w) of a. This is the reduction of Megiddo and Papadimitriou [MP91] and of Johnson, Papadimitriou and Yannakakis [JPY88] used for TFNP and its subclasses. For relations that need not be total, f must in addition map instances with a solution to instances with a solution (as in Levin reductions); otherwise a solver for S reporting that f a has no solution would say nothing about a. For a total target, this condition holds automatically (Cslib.Complexity.SearchReducible.of_isTotalSearch), so on TFNP the definition is exactly the one-way condition of the literature. A search reduction is in particular a polynomial-time many-one reduction between the domains (Cslib.Complexity.SearchReducible.polyTimeReducible).

Main definitions #

Main results #

References #

Search problems and solvers #

def Cslib.Complexity.searchDomain {α : Type} (R : α → List Bool → Prop) :
Set α

The instances of the search problem R that have a solution.

theorem Cslib.Complexity.mem_searchDomain {α : Type} {R : α → List Bool → Prop} {a : α} :
a ∈ searchDomain R ↔ ∃ (w : List Bool), R a w
def Cslib.Complexity.IsTotalSearch {α : Type} (R : α → List Bool → Prop) :

The search problem R is total: every instance has a solution.

def Cslib.Complexity.SolvesSearch {α : Type} (R : α → List Bool → Prop) (f : α → Option (List Bool)) :

f solves the search problem R: it returns some w only for a solution w, and none only on instances without solutions.

theorem Cslib.Complexity.SolvesSearch.rel {α : Type} {R : α → List Bool → Prop} {f : α → Option (List Bool)} (h : SolvesSearch R f) {a : α} {w : List Bool} (ha : f a = some w) :
R a w
theorem Cslib.Complexity.SolvesSearch.notMem {α : Type} {R : α → List Bool → Prop} {f : α → Option (List Bool)} (h : SolvesSearch R f) {a : α} (ha : f a = none) :
a ∉ searchDomain R
theorem Cslib.Complexity.SolvesSearch.isSome_iff {α : Type} {R : α → List Bool → Prop} {f : α → Option (List Bool)} (h : SolvesSearch R f) {a : α} :

A solver finds a solution exactly on the instances that have one.

theorem Cslib.Complexity.solvesSearch_some {α : Type} {R : α → List Bool → Prop} {g : α → List Bool} (hg : ∀ (a : α), R a (g a)) :
SolvesSearch R fun (a : α) => some (g a)

A function that always returns a solution solves the search problem.

theorem Cslib.Complexity.SolvesSearch.rel_getD {α : Type} {R : α → List Bool → Prop} {f : α → Option (List Bool)} (h : SolvesSearch R f) (htot : IsTotalSearch R) (a : α) (d : List Bool) :
R a ((f a).getD d)

A solver of a total search problem never returns none.

The classes #

def Cslib.Complexity.FNP {α : Type} (enc : α ↪ List Bool) :
Set (α → List Bool → Prop)

The search problems in FNP with respect to the encoding enc of instances: relations that are polynomially balanced, every solution of a having length at most p (enc a).length for a polynomial p, and decided by a polynomial-time function of the instance and the candidate solution Papadimitriou, Section 10.3.

def Cslib.Complexity.FPSearch {α : Type} (enc : α ↪ List Bool) :
Set (α → List Bool → Prop)

The search problems in FNP solved by a polynomial-time function, Papadimitriou's class FP of search problems Papadimitriou, Section 10.3.

def Cslib.Complexity.TFNP {α : Type} (enc : α ↪ List Bool) :
Set (α → List Bool → Prop)

The total search problems in FNP Megiddo and Papadimitriou.

theorem Cslib.Complexity.mem_FNP {α : Type} {enc : α ↪ List Bool} {R : α → List Bool → Prop} :
R ∈ FNP enc ↔ (∃ (p : Polynomial ℕ), ∀ (a : α) (w : List Bool), R a w → w.length ≤ Polynomial.eval (enc a).length p) ∧ ∃ (V : α × List Bool → Bool), Turing.MultiTapeTM.ComputableInPolyTime V (Turing.MultiTapeTM.encPair enc Turing.MultiTapeTM.encBits) Turing.MultiTapeTM.encBool ∧ ∀ (a : α) (w : List Bool), R a w ↔ V (a, w) = true
theorem Cslib.Complexity.mem_TFNP {α : Type} {enc : α ↪ List Bool} {R : α → List Bool → Prop} :
theorem Cslib.Complexity.FPSearch_subset_FNP {α : Type} {enc : α ↪ List Bool} :
FPSearch enc ⊆ FNP enc

Every search problem in FPSearch is in FNP.

theorem Cslib.Complexity.TFNP_subset_FNP {α : Type} {enc : α ↪ List Bool} :
TFNP enc ⊆ FNP enc

Every search problem in TFNP is in FNP.

FNP with the length bound in the verifier. A relation is in FNP exactly when it holds of the candidate solutions of length at most p (enc a).length accepted by a polynomial-time verifier.

theorem Cslib.Complexity.mem_FPSearch_of_total {α : Type} {enc : α ↪ List Bool} {R : α → List Bool → Prop} (hR : R ∈ FNP enc) {g : α → List Bool} (hg : Turing.MultiTapeTM.ComputableInPolyTime g enc Turing.MultiTapeTM.encBits) (h : ∀ (a : α), R a (g a)) :

A polynomial-time solver of a total relation in FNP puts it in FPSearch.

theorem Cslib.Complexity.exists_total_of_mem_FPSearch {α : Type} {enc : α ↪ List Bool} {R : α → List Bool → Prop} (hR : R ∈ FPSearch enc) (htot : IsTotalSearch R) :
∃ (g : α → List Bool), Turing.MultiTapeTM.ComputableInPolyTime g enc Turing.MultiTapeTM.encBits ∧ ∀ (a : α), R a (g a)

A total relation in FPSearch has a polynomial-time function returning a solution.

Domains and NP #

theorem Cslib.Complexity.searchDomain_mem_NP {α : Type} {enc : α ↪ List Bool} {R : α → List Bool → Prop} (hR : R ∈ FNP enc) :

Domains of FNP relations are in NP: a solution, framed and padded, is a certificate.

def Cslib.Complexity.verifierSearch {α : Type} (enc : α ↪ List Bool) (p : Polynomial ℕ) (V : α × List Bool → Bool) (a : α) (w : List Bool) :

The search problem of a verifier: the certificates of the prescribed length that it accepts.

theorem Cslib.Complexity.IsVerifier.searchDomain_eq {α : Type} {enc : α ↪ List Bool} {p : Polynomial ℕ} {V : α × List Bool → Bool} {A : Set α} (h : IsVerifier enc p V A) :

A verifier verifies exactly the domain of its search problem.

theorem Cslib.Complexity.mem_NP_iff_exists_FNP {α : Type} {enc : α ↪ List Bool} {A : Set α} :
A ∈ NP enc ↔ ∃ R ∈ FNP enc, searchDomain R = A

NP is the class of domains of FNP relations.

theorem Cslib.Complexity.searchDomain_mem_P {α : Type} {enc : α ↪ List Bool} {R : α → List Bool → Prop} (hR : R ∈ FPSearch enc) :

Domains of FPSearch relations are in P: test whether the solver finds a solution.

theorem Cslib.Complexity.NP_subset_P_of_FNP_subset_FPSearch {α : Type} {enc : α ↪ List Bool} (h : FNP enc ⊆ FPSearch enc) :
NP enc ⊆ P enc

If every FNP relation is in FPSearch, then NP ⊆ P for the encoding enc.

Disjoint sums and NP ∩ coNP #

def Cslib.Complexity.searchSum {α : Type} (R S : α → List Bool → Prop) (a : α) :

The disjoint sum of the search problems R and S: the solutions of a are true :: u for the solutions u of a in R, and false :: u for the solutions u of a in S.

@[simp]
theorem Cslib.Complexity.searchSum_nil {α : Type} {R S : α → List Bool → Prop} {a : α} :
@[simp]
theorem Cslib.Complexity.searchSum_true_cons {α : Type} {R S : α → List Bool → Prop} {a : α} {u : List Bool} :
searchSum R S a (true :: u) ↔ R a u
@[simp]
theorem Cslib.Complexity.searchSum_false_cons {α : Type} {R S : α → List Bool → Prop} {a : α} {u : List Bool} :
searchSum R S a (false :: u) ↔ S a u
theorem Cslib.Complexity.searchSum_mem_FNP {α : Type} {enc : α ↪ List Bool} {R S : α → List Bool → Prop} (hR : R ∈ FNP enc) (hS : S ∈ FNP enc) :
searchSum R S ∈ FNP enc

FNP is closed under disjoint sums.

theorem Cslib.Complexity.isTotalSearch_searchSum {α : Type} {R S : α → List Bool → Prop} (h : ∀ (a : α), a ∈ searchDomain R ∨ a ∈ searchDomain S) :

The disjoint sum of search problems whose domains cover all instances is total.

theorem Cslib.Complexity.searchSum_mem_TFNP {α : Type} {enc : α ↪ List Bool} {R S : α → List Bool → Prop} (hR : R ∈ FNP enc) (hS : S ∈ FNP enc) (h : ∀ (a : α), a ∈ searchDomain R ∨ a ∈ searchDomain S) :

The disjoint sum of FNP relations whose domains cover all instances is in TFNP.

theorem Cslib.Complexity.exists_searchSum_mem_TFNP {α : Type} {enc : α ↪ List Bool} {A : Set α} (hA : A ∈ NP enc) (hA' : A ∈ coNP enc) :
∃ (R : α → List Bool → Prop) (S : α → List Bool → Prop), searchDomain R = A ∧ searchDomain S = Aᶜ ∧ searchSum R S ∈ TFNP enc

Problems in NP ∩ coNP give total search problems: if A and its complement are in NP, then A and Aᶜ are domains of FNP relations whose disjoint sum is in TFNP.

Solving a disjoint sum decides the first domain. If the domains of R and S are disjoint and searchSum R S is in FPSearch, the domain of R is in P: an instance is in it exactly when the solver returns a solution tagged true.

theorem Cslib.Complexity.NP_inter_coNP_subset_P_of_TFNP_subset_FPSearch {α : Type} {enc : α ↪ List Bool} (h : TFNP enc ⊆ FPSearch enc) :
NP enc ∩ coNP enc ⊆ P enc

If every TFNP relation is in FPSearch, then NP ∩ coNP ⊆ P for the encoding enc [MP91].

Search reductions #

def Cslib.Complexity.SearchReducible {α β : Type} (encA : α ↪ List Bool) (encB : β ↪ List Bool) (R : α → List Bool → Prop) (S : β → List Bool → Prop) :

A polynomial-time search reduction from R to S: a polynomial-time map f of instances that maps instances with a solution to instances with a solution, and a polynomial-time map g taking a solution w of f a back to a solution g (a, w) of a.

def Cslib.Complexity.SearchHard {β : Type} (𝒞 : {α : Type} → (α ↪ List Bool) → Set (α → List Bool → Prop)) (encB : β ↪ List Bool) (S : β → List Bool → Prop) :

S is hard for the class 𝒞 of search problems under search reductions: every problem in 𝒞, with any encoding of its instances, reduces to S. This is HardUnder for SearchReducible.

def Cslib.Complexity.SearchComplete {β : Type} (𝒞 : {α : Type} → (α ↪ List Bool) → Set (α → List Bool → Prop)) (encB : β ↪ List Bool) (S : β → List Bool → Prop) :

S is complete for the class 𝒞 of search problems: it is in 𝒞 and hard for it. This is CompleteUnder for SearchReducible (searchComplete_iff_completeUnder), with its second conjunct stated as SearchHard.

theorem Cslib.Complexity.searchHard_iff_hardUnder {β : Type} {𝒞 : {α : Type} → (α ↪ List Bool) → Set (α → List Bool → Prop)} {encB : β ↪ List Bool} {S : β → List Bool → Prop} :
SearchHard (fun {α : Type} => 𝒞) encB S ↔ HardUnder (fun {α : Type} (enc : α ↪ List Bool) => SearchReducible enc encB) 𝒞 S

Search hardness is hardness under SearchReducible.

theorem Cslib.Complexity.searchComplete_iff_completeUnder {β : Type} {𝒞 : {α : Type} → (α ↪ List Bool) → Set (α → List Bool → Prop)} {encB : β ↪ List Bool} {S : β → List Bool → Prop} :
SearchComplete (fun {α : Type} => 𝒞) encB S ↔ CompleteUnder (fun {α : Type} (enc : α ↪ List Bool) => SearchReducible enc encB) 𝒞 encB S

Search completeness is completeness under SearchReducible.

theorem Cslib.Complexity.SearchReducible.of_isTotalSearch {α β : Type} {R : α → List Bool → Prop} {encA : α ↪ List Bool} {encB : β ↪ List Bool} {T : β → List Bool → Prop} (hT : IsTotalSearch T) {f : α → β} {g : α × List Bool → List Bool} (hf : Turing.MultiTapeTM.ComputableInPolyTime f encA encB) (hg : Turing.MultiTapeTM.ComputableInPolyTime g (Turing.MultiTapeTM.encPair encA Turing.MultiTapeTM.encBits) Turing.MultiTapeTM.encBits) (h : ∀ (a : α) (w : List Bool), T (f a) w → R a (g (a, w))) :
SearchReducible encA encB R T

For a total target, the one-way condition on solutions suffices for a search reduction.

theorem Cslib.Complexity.SearchReducible.refl {α : Type} (encA : α ↪ List Bool) (R : α → List Bool → Prop) :
SearchReducible encA encA R R

Every search problem reduces to itself.

theorem Cslib.Complexity.SearchReducible.trans {α β γ : Type} {R : α → List Bool → Prop} {encA : α ↪ List Bool} {encB : β ↪ List Bool} {encC : γ ↪ List Bool} {T : β → List Bool → Prop} {U : γ → List Bool → Prop} (hRT : SearchReducible encA encB R T) (hTU : SearchReducible encB encC T U) :
SearchReducible encA encC R U

Search reductions compose.

theorem Cslib.Complexity.SearchReducible.exists_reindex {α β : Type} {R : α → List Bool → Prop} {encA : α ↪ List Bool} {encB : β ↪ List Bool} {T : β → List Bool → Prop} (h : SearchReducible encA encB R T) :
∃ (f : α → β), Turing.MultiTapeTM.ComputableInPolyTime f encA encB ∧ SearchReducible encA encA R fun (a : α) => T (f a)

A search reduction to T on another instance type yields a search reduction, on the same instance type, to the pullback fun a => T (f a) along its polynomial-time instance map f. Classes defined by reductions to uniform families on the instance type itself use this to absorb reductions across instance types.

theorem Cslib.Complexity.SearchReducible.polyTimeReducible {α β : Type} {R : α → List Bool → Prop} {encA : α ↪ List Bool} {encB : β ↪ List Bool} {T : β → List Bool → Prop} (h : SearchReducible encA encB R T) :

A search reduction is a polynomial-time many-one reduction between the domains.

theorem Cslib.Complexity.SearchReducible.isTotalSearch {α β : Type} {R : α → List Bool → Prop} {encA : α ↪ List Bool} {encB : β ↪ List Bool} {T : β → List Bool → Prop} (h : SearchReducible encA encB R T) (hT : IsTotalSearch T) :

Totality transfers backwards along search reductions.

theorem Cslib.Complexity.SearchReducible.mem_TFNP {α β : Type} {R : α → List Bool → Prop} {encA : α ↪ List Bool} {encB : β ↪ List Bool} {T : β → List Bool → Prop} (h : SearchReducible encA encB R T) (hR : R ∈ FNP encA) (hT : T ∈ TFNP encB) :
R ∈ TFNP encA

An FNP relation that reduces to a TFNP relation is in TFNP.

theorem Cslib.Complexity.SearchReducible.mem_FPSearch {α β : Type} {R : α → List Bool → Prop} {encA : α ↪ List Bool} {encB : β ↪ List Bool} {T : β → List Bool → Prop} (h : SearchReducible encA encB R T) (hR : R ∈ FNP encA) (hT : T ∈ FPSearch encB) :
R ∈ FPSearch encA

FPSearch is closed under search reductions: an FNP relation that reduces to a relation in FPSearch is in FPSearch.

theorem Cslib.Complexity.SearchHard.trans {β γ : Type} {encB : β ↪ List Bool} {encC : γ ↪ List Bool} {T : β → List Bool → Prop} {U : γ → List Bool → Prop} {𝒞 : {α : Type} → (α ↪ List Bool) → Set (α → List Bool → Prop)} (hT : SearchHard (fun {α : Type} => 𝒞) encB T) (hTU : SearchReducible encB encC T U) :
SearchHard (fun {α : Type} => 𝒞) encC U

Hardness transfers along search reductions.

theorem Cslib.Complexity.SearchHard.subset_FPSearch {α β : Type} {encB : β ↪ List Bool} {T : β → List Bool → Prop} {𝒞 : {α : Type} → (α ↪ List Bool) → Set (α → List Bool → Prop)} (h𝒞 : ∀ {α : Type} (enc : α ↪ List Bool), 𝒞 enc ⊆ FNP enc) (hT : SearchHard (fun {α : Type} => 𝒞) encB T) (hT' : T ∈ FPSearch encB) (enc : α ↪ List Bool) :
𝒞 enc ⊆ FPSearch enc

A hard problem in FPSearch collapses the class. If every problem of 𝒞 is in FNP and a 𝒞-hard problem is in FPSearch, then every problem of 𝒞 is in FPSearch.

theorem Cslib.Complexity.SearchComplete.TFNP_subset_FPSearch_iff {β : Type} {encB : β ↪ List Bool} {T : β → List Bool → Prop} (hT : SearchComplete (@TFNP) encB T) :
T ∈ FPSearch encB ↔ ∀ {α : Type} (enc : α ↪ List Bool), TFNP enc ⊆ FPSearch enc

A TFNP-complete problem is in FPSearch exactly when all of TFNP is.