Documentation

CslibFrontier.Computability.Complexity.FineGrained.FunctionRates

Parameterized time bounds for functions #

Cslib.Complexity.DecidableInTimeO, DecidableInExpTime and DecidableInSubexpTime measure the running time of decision problems in a structural parameter μ : α → ℕ of the instance rather than in the bit length L = (encIn a).length alone. This module develops the same three notions for functions: f is computable within time O(T a), within time 2 ^ (δ * μ a) times a polynomial in L, and within that time for every δ > 0. It bridges them to Cslib.Complexity.FTIME and to decision, and transfers them along polynomial-time reductions that change the parameter linearly.

Main definitions #

Main results #

Parameterized function time bounds #

def Cslib.Complexity.ComputableInTimeO {α : Type u_1} {β : Type u_2} (f : α → β) (encIn : α ↪ List Bool) (encOut : β ↪ List Bool) (T : α → ℝ) :

f is computable within time O(T a) on the instance a: within time c * T a + c, for a constant c, by a native multi-tape machine reading encIn a and writing encOut (f a) with some workspace bound.

theorem Cslib.Complexity.ComputableInTimeO.mono {α : Type u_1} {β : Type u_2} {encIn : α ↪ List Bool} {encOut : β ↪ List Bool} {f : α → β} {T T' : α → ℝ} (h : ComputableInTimeO f encIn encOut T) (c : ℕ) (hT : ∀ (a : α), T a ≤ ↑c * T' a + ↑c) (hT' : ∀ (a : α), 0 ≤ T' a) :
ComputableInTimeO f encIn encOut T'

Weakening the bound of ComputableInTimeO up to constants.

def Cslib.Complexity.ComputableInExpTime {α : Type u_1} {β : Type u_2} (f : α → β) (encIn : α ↪ List Bool) (encOut : β ↪ List Bool) (μ : α → ℕ) (δ : ℝ) :

f is computable within time 2 ^ (δ * μ a) times a polynomial in the encoded input length: within time O(2 ^ (δ * μ a) * (L + 1) ^ e) for some e.

def Cslib.Complexity.ComputableInSubexpTime {α : Type u_1} {β : Type u_2} (f : α → β) (encIn : α ↪ List Bool) (encOut : β ↪ List Bool) (μ : α → ℕ) :

f is computable in subexponential time in μ: within time 2 ^ (δ * μ a) times a polynomial in the encoded input length for every δ > 0 (the machine and polynomial degree may depend on δ).

theorem Cslib.Complexity.ComputableInExpTime.mono {α : Type u_1} {β : Type u_2} {encIn : α ↪ List Bool} {encOut : β ↪ List Bool} {f : α → β} {μ : α → ℕ} {δ δ' : ℝ} (h : ComputableInExpTime f encIn encOut μ δ) (hδ : δ ≤ δ') :
ComputableInExpTime f encIn encOut μ δ'

Larger exponents allow more functions.

theorem Cslib.Complexity.ComputableInExpTime.mono_measure {α : Type u_1} {β : Type u_2} {encIn : α ↪ List Bool} {encOut : β ↪ List Bool} {f : α → β} {μ μ' : α → ℕ} {c : ℕ} (hμ : ∀ (a : α), μ a ≤ c * μ' a + c) {δ : ℝ} (hδ : 0 ≤ δ) (h : ComputableInExpTime f encIn encOut μ δ) :
ComputableInExpTime f encIn encOut μ' (↑c * δ)

Rescaling the parameter linearly rescales the exponential rate.

theorem Cslib.Complexity.ComputableInSubexpTime.mono_measure {α : Type u_1} {β : Type u_2} {encIn : α ↪ List Bool} {encOut : β ↪ List Bool} {f : α → β} {μ μ' : α → ℕ} {c : ℕ} (hμ : ∀ (a : α), μ a ≤ c * μ' a + c) (h : ComputableInSubexpTime f encIn encOut μ) :
ComputableInSubexpTime f encIn encOut μ'

Subexponential computability transfers to any parameter at least linear in μ.

theorem Cslib.Complexity.decidableInTimeO_iff_exists_computableInTimeO {α : Type u_1} {encIn : α ↪ List Bool} {T : α → ℝ} {A : Set α} :
DecidableInTimeO A encIn T ↔ ∃ (g : α → Bool), (∀ (a : α), a ∈ A ↔ g a = true) ∧ ComputableInTimeO g encIn Turing.MultiTapeTM.encBool T

DecidableInTimeO is ComputableInTimeO of a Boolean indicator function.

theorem Cslib.Complexity.mem_FTIME_iff_computableInTimeO {α β : Type} {encIn : α ↪ List Bool} {encMid : β ↪ List Bool} {f : α → β} {t : ℕ → ℕ} :
f ∈ FTIME encIn encMid t ↔ ComputableInTimeO f encIn encMid fun (a : α) => ↑(t (encIn a).length)

FTIME in terms of ComputableInTimeO. For a bound depending only on the encoded input length, ComputableInTimeO agrees with membership in FTIME.

theorem Cslib.Complexity.ComputableInTimeO.exists_computableInO {α β : Type} {encIn : α ↪ List Bool} {encMid : β ↪ List Bool} {f : α → β} {T : α → ℝ} (h : ComputableInTimeO f encIn encMid T) :
∃ (t : α → ℕ) (c : ℕ), Turing.MultiTapeTM.ComputableInO f encIn encMid t t ∧ ∀ (a : α), ↑(t a) ≤ ↑c * T a + ↑c

A function computable within time O(T) has a ComputableInO certificate within time and charged workspace O(t), for a natural clock t within O(T).

theorem Cslib.Complexity.ComputableInTimeO.of_computableInO {α β : Type} {encIn : α ↪ List Bool} {encMid : β ↪ List Bool} {f : α → β} {T : α → ℝ} {t S : α → ℕ} (hf : Turing.MultiTapeTM.ComputableInO f encIn encMid t S) (hT : ∀ (a : α), ↑(t a) ≤ T a) :
ComputableInTimeO f encIn encMid T

A ComputableInO certificate within time t ≤ T gives ComputableInTimeO within T.

theorem Cslib.Complexity.ComputableInExpTime.of_computableInO {α β : Type} {encIn : α ↪ List Bool} {encMid : β ↪ List Bool} {f : α → β} {μ : α → ℕ} {δ : ℝ} {t S : α → ℕ} (hf : Turing.MultiTapeTM.ComputableInO f encIn encMid t S) (c e : ℕ) (ht : ∀ (a : α), ↑(t a) ≤ ↑c * (2 ^ (δ * ↑(μ a)) * (↑(encIn a).length + 1) ^ e)) :
ComputableInExpTime f encIn encMid μ δ

A ComputableInO certificate within c * (2 ^ (δ * μ a) * (L + 1) ^ e) gives ComputableInExpTime.

theorem Cslib.Complexity.ComputableInExpTime.of_computableInPolyTime {α β : Type} {encIn : α ↪ List Bool} {encMid : β ↪ List Bool} {f : α → β} {μ : α → ℕ} (hf : Turing.MultiTapeTM.ComputableInPolyTime f encIn encMid) :
ComputableInExpTime f encIn encMid μ 0

Every polynomial-time computable function has exponential rate 0 in any parameter μ.

theorem Cslib.Complexity.ComputableInTimeO.ite_polyTime_of_le {α β : Type} {encIn : α ↪ List Bool} {encMid : β ↪ List Bool} {f : α → β} {x y : α → ℝ} {e : ℕ} {p : α → Bool} {g : α → β} (hf : ComputableInTimeO f encIn encMid fun (a : α) => 2 ^ x a * (↑(encIn a).length + 1) ^ e) (hp : Turing.MultiTapeTM.ComputableInPolyTime p encIn Turing.MultiTapeTM.encBool) (hg : Turing.MultiTapeTM.ComputableInPolyTime g encIn encMid) (hy : ∀ (a : α), 0 ≤ y a) (hxy : ∀ (a : α), p a = true → x a ≤ y a) :
∃ (e' : ℕ), ComputableInTimeO (fun (a : α) => if p a = true then f a else g a) encIn encMid fun (a : α) => 2 ^ y a * (↑(encIn a).length + 1) ^ e'

Guarding by a polynomial-time test. If f is computable within time O(2 ^ x a * (L + 1) ^ e) and p, g are computable in polynomial time, then if p a then f a else g a is computable within time O(2 ^ y a * (L + 1) ^ e') for some e', for any nonnegative exponent y that is at least x wherever the test p passes.

theorem Cslib.Complexity.ComputableInExpTime.ite_polyTime {α β : Type} {encIn : α ↪ List Bool} {encMid : β ↪ List Bool} {f : α → β} {μ : α → ℕ} {δ : ℝ} (hδ : 0 ≤ δ) {p : α → Bool} {g : α → β} (hp : Turing.MultiTapeTM.ComputableInPolyTime p encIn Turing.MultiTapeTM.encBool) (hf : ComputableInExpTime f encIn encMid μ δ) (hg : Turing.MultiTapeTM.ComputableInPolyTime g encIn encMid) :
ComputableInExpTime (fun (a : α) => if p a = true then f a else g a) encIn encMid μ δ

Guarding an exponential-time function by a polynomial-time test and fallback preserves rate δ ≥ 0.

theorem Cslib.Complexity.DecidableInTimeO.of_computableInTimeO_polyBounded {α β : Type} {encIn : α ↪ List Bool} {encMid : β ↪ List Bool} {f : α → β} {x : α → ℝ} {e : ℕ} (hx : ∀ (a : α), 0 ≤ x a) (hf : ComputableInTimeO f encIn encMid fun (a : α) => 2 ^ x a * (↑(encIn a).length + 1) ^ e) (hlen : Turing.MultiTapeTM.PolyBounded (fun (a : α) => (encIn a).length) fun (a : α) => (encMid (f a)).length) {test : β → Bool} (htest : Turing.MultiTapeTM.ComputableInPolyTime test encMid Turing.MultiTapeTM.encBool) :
∃ (e' : ℕ), DecidableInTimeO {a : α | test (f a) = true} encIn fun (a : α) => 2 ^ x a * (↑(encIn a).length + 1) ^ e'

Decision from function computation. If f is computable within time O(2 ^ x a * (L + 1) ^ e) for a nonnegative exponent x and its encoded output length is polynomially bounded in L, then any polynomial-time test on f a decides {a | test (f a) = true} within time O(2 ^ x a * (L + 1) ^ e') for some e'.

theorem Cslib.Complexity.DecidableInExpTime.of_computableInExpTime_polyBounded {α β : Type} {encIn : α ↪ List Bool} {encMid : β ↪ List Bool} {f : α → β} {μ : α → ℕ} {δ : ℝ} (hδ : 0 ≤ δ) (hf : ComputableInExpTime f encIn encMid μ δ) (hlen : Turing.MultiTapeTM.PolyBounded (fun (a : α) => (encIn a).length) fun (a : α) => (encMid (f a)).length) {test : β → Bool} (htest : Turing.MultiTapeTM.ComputableInPolyTime test encMid Turing.MultiTapeTM.encBool) :
DecidableInExpTime {a : α | test (f a) = true} encIn μ δ

Exact-rate decision from function computation. If f is computable in time 2 ^ (δ * μ a) · poly(|a|) (δ ≥ 0) and its encoded output length is polynomially bounded in |a|, then any polynomial-time test on f a decides {a | test (f a) = true} at the same exponential rate δ.

theorem Cslib.Complexity.DecidableInSubexpTime.of_computableInSubexpTime_polyBounded {α β : Type} {encIn : α ↪ List Bool} {encMid : β ↪ List Bool} {f : α → β} {μ : α → ℕ} (hf : ComputableInSubexpTime f encIn encMid μ) (hlen : Turing.MultiTapeTM.PolyBounded (fun (a : α) => (encIn a).length) fun (a : α) => (encMid (f a)).length) {test : β → Bool} (htest : Turing.MultiTapeTM.ComputableInPolyTime test encMid Turing.MultiTapeTM.encBool) :
DecidableInSubexpTime {a : α | test (f a) = true} encIn μ

Subexponential function computation with polynomially bounded output length transfers to subexponential decision for any polynomial-time output predicate.

theorem Cslib.Complexity.ComputableInExpTime.of_reduction {α β γ : Type} {encIn : α ↪ List Bool} {encMid : β ↪ List Bool} {encOut : γ ↪ List Bool} {μA : α → ℕ} {μB : β → ℕ} {r : α → β} {g : β → γ} (hr : Turing.MultiTapeTM.ComputableInPolyTime r encIn encMid) {c : ℕ} (hμ : ∀ (a : α), μB (r a) ≤ c * μA a + c) {δ : ℝ} (hδ : 0 ≤ δ) (hg : ComputableInExpTime g encMid encOut μB δ) :
ComputableInExpTime (g ∘ r) encIn encOut μA (↑c * δ)

Transfer along linear-parameter parsimonious reductions. If r : α → β is computable in polynomial time with μB (r a) ≤ c * μA a + c, and g : β → γ is computable in time 2 ^ (δ * μB b) · poly(|b|) (δ ≥ 0), then g ∘ r is computable in time 2 ^ (c * δ * μA a) · poly(|a|).

theorem Cslib.Complexity.ComputableInSubexpTime.of_reduction {α β γ : Type} {encIn : α ↪ List Bool} {encMid : β ↪ List Bool} {encOut : γ ↪ List Bool} {μA : α → ℕ} {μB : β → ℕ} {r : α → β} {g : β → γ} (hr : Turing.MultiTapeTM.ComputableInPolyTime r encIn encMid) {c : ℕ} (hμ : ∀ (a : α), μB (r a) ≤ c * μA a + c) (hg : ComputableInSubexpTime g encMid encOut μB) :
ComputableInSubexpTime (g ∘ r) encIn encOut μA

Subexponential function computation transfers along linear-parameter polynomial-time reductions.