Documentation

CslibFrontier.Computability.GenericRAM.Native.ExpTimePolySpace

Certificates in factored time and polynomial space #

A native certificate runs in time K times a polynomial and in polynomial space (Cslib.GenericRAM.NativeCertificate.FactorTimePolySpace) when, for constants C and d, its time is at most C K a (n + 1) ^ d and its space at most C (n + 1) ^ d on inputs a of encoded length n. Because a polynomial space bound also bounds the encoded intermediate value (Cslib.GenericRAM.NativeCertificate.polyBounded_length_of_space), this shape closes under pairing, sequential composition, conditional branching and retained-input option elimination, recovering Cslib.GenericRAM.NativeCertificate.ExpTimePolySpace at K a = 2 ^ E a.

Main definitions #

Main results #

theorem Cslib.GenericRAM.NativeCertificate.polyBounded_length_of_space {α β : Type} {enc : α ↪ List Bool} {eβ : β ↪ List Bool} {f : α → β} {c : NativeCertificate f enc eβ} (hs : Turing.MultiTapeTM.PolyBounded (fun (a : α) => (enc a).length) c.space) :
Turing.MultiTapeTM.PolyBounded (fun (a : α) => (enc a).length) fun (a : α) => (eβ (f a)).length

A polynomial space bound on a native certificate also polynomially bounds the encoded output length.

theorem Cslib.GenericRAM.NativeCertificate.computableInPolySpace {α β : Type} {enc : α ↪ List Bool} {eβ : β ↪ List Bool} {f : α → β} (c : NativeCertificate f enc eβ) (hs : Turing.MultiTapeTM.PolyBounded (fun (a : α) => (enc a).length) c.space) :

A native certificate with polynomially bounded workspace witnesses ComputableInPolySpace, regardless of its running time.

def Cslib.GenericRAM.NativeCertificate.FactorTimePolySpace {α β : Type} {enc : α ↪ List Bool} {eβ : β ↪ List Bool} {f : α → β} (c : NativeCertificate f enc eβ) (K : α → ℕ) :

A certificate runs in time K times a polynomial and in polynomial space: for constants C and d, its time is at most C K a (n + 1) ^ d and its space at most C (n + 1) ^ d on inputs a of encoded length n.

theorem Cslib.GenericRAM.NativeCertificate.FactorTimePolySpace.space_polyBounded {α β : Type} {enc : α ↪ List Bool} {eβ : β ↪ List Bool} {f : α → β} {c : NativeCertificate f enc eβ} {K : α → ℕ} (h : c.FactorTimePolySpace K) :
Turing.MultiTapeTM.PolyBounded (fun (a : α) => (enc a).length) c.space
theorem Cslib.GenericRAM.NativeCertificate.FactorTimePolySpace.exists_time_polyBounded {α β : Type} {enc : α ↪ List Bool} {eβ : β ↪ List Bool} {f : α → β} {c : NativeCertificate f enc eβ} {K : α → ℕ} (h : c.FactorTimePolySpace K) :
∃ (T : α → ℕ), Turing.MultiTapeTM.PolyBounded (fun (a : α) => (enc a).length) T ∧ ∀ (a : α), c.time a ≤ K a * T a
theorem Cslib.GenericRAM.NativeCertificate.FactorTimePolySpace.of_polyBounded {α β : Type} {enc : α ↪ List Bool} {eβ : β ↪ List Bool} {f : α → β} {c : NativeCertificate f enc eβ} {K T : α → ℕ} (hT : Turing.MultiTapeTM.PolyBounded (fun (a : α) => (enc a).length) T) (hS : Turing.MultiTapeTM.PolyBounded (fun (a : α) => (enc a).length) c.space) (ht : ∀ (a : α), c.time a ≤ K a * T a) :

Package polynomial space and a factored time bound c.time a ≤ K a * T a with polynomial T.

theorem Cslib.GenericRAM.NativeCertificate.FactorTimePolySpace.mono_const {α β : Type} {enc : α ↪ List Bool} {eβ : β ↪ List Bool} {f : α → β} {c : NativeCertificate f enc eβ} {K K' : α → ℕ} (h : c.FactorTimePolySpace K) (M : ℕ) (hK : ∀ (a : α), K a ≤ M * K' a) :
theorem Cslib.GenericRAM.NativeCertificate.FactorTimePolySpace.mono {α β : Type} {enc : α ↪ List Bool} {eβ : β ↪ List Bool} {f : α → β} {c : NativeCertificate f enc eβ} {K K' : α → ℕ} (h : c.FactorTimePolySpace K) (hK : ∀ (a : α), K a ≤ K' a) :
theorem Cslib.GenericRAM.NativeCertificate.FactorTimePolySpace.absorb_polyBounded {α β : Type} {enc : α ↪ List Bool} {eβ : β ↪ List Bool} {f : α → β} {c : NativeCertificate f enc eβ} {K M : α → ℕ} (h : c.FactorTimePolySpace fun (a : α) => M a * K a) (hM : Turing.MultiTapeTM.PolyBounded (fun (a : α) => (enc a).length) M) :

A polynomially bounded factor in M a * K a is absorbed into the polynomial overhead.

theorem Cslib.GenericRAM.NativeCertificate.FactorTimePolySpace.ofIsPolynomial {α β : Type} {enc : α ↪ List Bool} {eβ : β ↪ List Bool} {f : α → β} {c : NativeCertificate f enc eβ} (hc : c.IsPolynomial) :
c.FactorTimePolySpace fun (x : α) => 1
theorem Cslib.GenericRAM.NativeCertificate.FactorTimePolySpace.congr {α β : Type} {enc : α ↪ List Bool} {eβ : β ↪ List Bool} {f : α → β} {c : NativeCertificate f enc eβ} {K : α → ℕ} {f' : α → β} (h : c.FactorTimePolySpace K) (hfg : ∀ (a : α), f a = f' a) :
theorem Cslib.GenericRAM.NativeCertificate.FactorTimePolySpace.snd {α β γ : Type} {enc : α ↪ List Bool} {eβ : β ↪ List Bool} {eγ : γ ↪ List Bool} {K : α → ℕ} {f : α → β × γ} {c : NativeCertificate f enc (Turing.MultiTapeTM.encPair eβ eγ)} (h : c.FactorTimePolySpace K) :
theorem Cslib.GenericRAM.NativeCertificate.FactorTimePolySpace.prod {α β γ : Type} {enc : α ↪ List Bool} {eβ : β ↪ List Bool} {eγ : γ ↪ List Bool} {f : α → β} {g : α → γ} {c : NativeCertificate f enc eβ} {K K' : α → ℕ} {c' : NativeCertificate g enc eγ} (h : c.FactorTimePolySpace K) (h' : c'.FactorTimePolySpace K') :
(c.prod c').FactorTimePolySpace fun (a : α) => K a + K' a

Pairs add the time factors while retaining polynomial workspace.

theorem Cslib.GenericRAM.NativeCertificate.FactorTimePolySpace.prod_same {α β γ : Type} {enc : α ↪ List Bool} {eβ : β ↪ List Bool} {eγ : γ ↪ List Bool} {f : α → β} {g : α → γ} {c : NativeCertificate f enc eβ} {K : α → ℕ} {c' : NativeCertificate g enc eγ} (h : c.FactorTimePolySpace K) (h' : c'.FactorTimePolySpace K) :
theorem Cslib.GenericRAM.NativeCertificate.FactorTimePolySpace.comp {α β γ : Type} {enc : α ↪ List Bool} {eβ : β ↪ List Bool} {eγ : γ ↪ List Bool} {f : α → β} {c : NativeCertificate f enc eβ} {K : α → ℕ} {r : β → γ} {c₂ : NativeCertificate r eβ eγ} {K₂ : β → ℕ} (h₁ : c.FactorTimePolySpace K) (h₂ : c₂.FactorTimePolySpace K₂) :
(c₂.comp c).FactorTimePolySpace fun (a : α) => K a + K₂ (f a)

Sequential composition adds the producer's factor and the consumer's factor evaluated at the intermediate value, whose encoded length is polynomially bounded by the producer's workspace.

theorem Cslib.GenericRAM.NativeCertificate.FactorTimePolySpace.comp_ofPolyTime {α β γ : Type} {enc : α ↪ List Bool} {eβ : β ↪ List Bool} {eγ : γ ↪ List Bool} {f : α → β} {c : NativeCertificate f enc eβ} {K : α → ℕ} (h : c.FactorTimePolySpace K) (hK : ∀ (a : α), 1 ≤ K a) {r : β → γ} (hr : Turing.MultiTapeTM.ComputableInPolyTime r eβ eγ) :

Polynomial-time postprocessing preserves the factor when 1 ≤ K a.

theorem Cslib.GenericRAM.NativeCertificate.FactorTimePolySpace.comp_polyPre {α β γ : Type} {enc : α ↪ List Bool} {eβ : β ↪ List Bool} {eγ : γ ↪ List Bool} {f : α → β} {r : β → γ} {c₂ : NativeCertificate r eβ eγ} {K₂ : β → ℕ} (h : c₂.FactorTimePolySpace K₂) (hf : Turing.MultiTapeTM.ComputableInPolyTime f enc eβ) (hK : ∀ (a : α), 1 ≤ K₂ (f a)) :
(c₂.comp (NativeCertificate.ofPolyTime hf)).FactorTimePolySpace fun (a : α) => K₂ (f a)

Polynomial-time preprocessing pulls back the factor when 1 ≤ K₂ (f a).

theorem Cslib.GenericRAM.NativeCertificate.FactorTimePolySpace.branch {α β : Type} {enc : α ↪ List Bool} {eβ : β ↪ List Bool} {K : α → ℕ} {condition : α → Bool} {f₁ f₂ : α → β} {test : NativeCertificate condition enc Turing.MultiTapeTM.encBool} {yes : NativeCertificate f₁ enc eβ} {no : NativeCertificate f₂ enc eβ} {Ky : α → ℕ} (ht : test.FactorTimePolySpace K) (hy : yes.FactorTimePolySpace Ky) (hcond : ∀ (a : α), condition a = true → Ky a ≤ K a) (hn : no.FactorTimePolySpace K) :
(test.branch yes no).FactorTimePolySpace K

Selected-branch conditional: the yes factor need only be bounded by K where condition holds.

theorem Cslib.GenericRAM.NativeCertificate.FactorTimePolySpace.option {α β γ : Type} {enc : α ↪ List Bool} {eβ : β ↪ List Bool} {eγ : γ ↪ List Bool} {K : α → ℕ} {value : α → Option β} {fallback : α → γ} {body : α × β → γ} {cVal : NativeCertificate value enc (Turing.MultiTapeTM.encOption eβ)} {cNone : NativeCertificate fallback enc eγ} {cSome : NativeCertificate body (Turing.MultiTapeTM.encPair enc eβ) eγ} {Ksome : α × β → ℕ} (hK : ∀ (a : α), 1 ≤ K a) (hval : cVal.FactorTimePolySpace K) (hnone : cNone.FactorTimePolySpace K) (hsome : cSome.FactorTimePolySpace Ksome) (hcond : ∀ (a : α) (b : β), value a = Option.some b → Ksome (a, b) ≤ K a) :
(cVal.option cNone cSome).FactorTimePolySpace K

Retained-input option elimination: the some factor need only be bounded by K a on pairs (a, b) with value a = Option.some b, whose encoded length is polynomially bounded by cVal's workspace.

theorem Cslib.GenericRAM.NativeCertificate.FactorTimePolySpace.polyTime {α β : Type} {enc : α ↪ List Bool} {eβ : β ↪ List Bool} {f : α → β} {c : NativeCertificate f enc eβ} {K : α → ℕ} (h : c.FactorTimePolySpace K) (hK : Turing.MultiTapeTM.PolyBounded (fun (a : α) => (enc a).length) K) :

When the factor K is itself polynomially bounded, the certificate computes f in polynomial time.

theorem Cslib.GenericRAM.NativeCertificate.FactorTimePolySpace.exists_mono_poly {α β : Type} {enc : α ↪ List Bool} {eβ : β ↪ List Bool} {f : α → β} {c : NativeCertificate f enc eβ} {K : α → ℕ} (h : c.FactorTimePolySpace K) :
∃ (poly : ℕ → ℕ), PolynomiallyBounded poly ∧ Monotone poly ∧ ∀ (a : α), c.time a ≤ K a * poly (enc a).length ∧ c.space a ≤ poly (enc a).length

Extract a single monotone polynomial poly bounding c.time a ≤ K a * poly n and c.space a ≤ poly n.

theorem Cslib.GenericRAM.NativeCertificate.FactorTimePolySpace.computableInO {α β : Type} {enc : α ↪ List Bool} {eβ : β ↪ List Bool} {f : α → β} {c : NativeCertificate f enc eβ} {K : α → ℕ} (h : c.FactorTimePolySpace K) :
∃ (e : ℕ), Turing.MultiTapeTM.ComputableInO f enc eβ (fun (a : α) => K a * ((enc a).length + 1) ^ e) fun (a : α) => ((enc a).length + 1) ^ e

The machine bounds of a certificate in time K times a polynomial and polynomial space.

theorem Cslib.GenericRAM.NativeCertificate.FactorTimePolySpace.exists_poly_computableInO {α β : Type} {enc : α ↪ List Bool} {eβ : β ↪ List Bool} {f : α → β} {c : NativeCertificate f enc eβ} {K : α → ℕ} (h : c.FactorTimePolySpace K) :
∃ (poly : ℕ → ℕ), PolynomiallyBounded poly ∧ Turing.MultiTapeTM.ComputableInO f enc eβ (fun (a : α) => K a * poly (enc a).length) fun (a : α) => poly (enc a).length

Existential polynomial form of computableInO.

def Cslib.GenericRAM.NativeCertificate.ExpTimePolySpace {α β : Type} {enc : α ↪ List Bool} {eβ : β ↪ List Bool} {f : α → β} (c : NativeCertificate f enc eβ) (E : α → ℕ) :

A certificate runs in time 2 ^ E times a polynomial and in polynomial space: for constants C and d, its time is at most C 2 ^ E a (n + 1) ^ d and its space at most C (n + 1) ^ d on inputs a of encoded length n.

theorem Cslib.GenericRAM.NativeCertificate.ExpTimePolySpace.mono {α β : Type} {enc : α ↪ List Bool} {eβ : β ↪ List Bool} {f : α → β} {c : NativeCertificate f enc eβ} {E E' : α → ℕ} (h : c.ExpTimePolySpace E) (hE : ∀ (a : α), E a ≤ E' a) :
theorem Cslib.GenericRAM.NativeCertificate.ExpTimePolySpace.prod {α β γ : Type} {enc : α ↪ List Bool} {eβ : β ↪ List Bool} {eγ : γ ↪ List Bool} {f : α → β} {g : α → γ} {c : NativeCertificate f enc eβ} {E E' : α → ℕ} {c' : NativeCertificate g enc eγ} (h : c.ExpTimePolySpace E) (h' : c'.ExpTimePolySpace E') :
(c.prod c').ExpTimePolySpace fun (a : α) => E a + E' a

Pairs add the exponents.

theorem Cslib.GenericRAM.NativeCertificate.ExpTimePolySpace.comp_ofPolyTime {α β γ : Type} {enc : α ↪ List Bool} {eβ : β ↪ List Bool} {eγ : γ ↪ List Bool} {f : α → β} {c : NativeCertificate f enc eβ} {E : α → ℕ} (h : c.ExpTimePolySpace E) {r : β → γ} (hr : Turing.MultiTapeTM.ComputableInPolyTime r eβ eγ) :

Polynomial-time postprocessing keeps the shape: the polynomial space bound also bounds the encoded intermediate value, on which the postprocessing runs.

theorem Cslib.GenericRAM.NativeCertificate.ExpTimePolySpace.computableInO {α β : Type} {enc : α ↪ List Bool} {eβ : β ↪ List Bool} {f : α → β} {c : NativeCertificate f enc eβ} {E : α → ℕ} (h : c.ExpTimePolySpace E) :
∃ (e : ℕ), Turing.MultiTapeTM.ComputableInO f enc eβ (fun (a : α) => 2 ^ E a * ((enc a).length + 1) ^ e) fun (a : α) => ((enc a).length + 1) ^ e

The machine bounds of a certificate in time 2 ^ E times a polynomial and polynomial space.

theorem Cslib.GenericRAM.NativeCertificate.expTimePolySpace_ofPolyTime {α β : Type} {enc : α ↪ List Bool} {eβ : β ↪ List Bool} {f : α → β} (hf : Turing.MultiTapeTM.ComputableInPolyTime f enc eβ) (E : α → ℕ) :

Polynomial-time certificates run in time 2 ^ E times a polynomial for every E.

theorem Cslib.GenericRAM.NativeCertificate.branch_bounds_of_two_pow {α β : Type} {enc : α ↪ List Bool} {eβ : β ↪ List Bool} {condition : α → Bool} {f₁ f₂ : α → β} {test : NativeCertificate condition enc Turing.MultiTapeTM.encBool} {yes : NativeCertificate f₁ enc eβ} {no : NativeCertificate f₂ enc eβ} (ht : test.IsPolynomial) (hn : no.IsPolynomial) (hys : Turing.MultiTapeTM.PolyBounded (fun (a : α) => (enc a).length) yes.space) {N Ty : α → ℕ} (hTy : Turing.MultiTapeTM.PolyBounded (fun (a : α) => (enc a).length) Ty) (hyt : ∀ (a : α), condition a = true → yes.time a ≤ 2 ^ N a * Ty a) :
Turing.MultiTapeTM.PolyBounded (fun (a : α) => (enc a).length) (test.branch yes no).space ∧ ∃ (T : α → ℕ), Turing.MultiTapeTM.PolyBounded (fun (a : α) => (enc a).length) T ∧ ∀ (a : α), (test.branch yes no).time a ≤ 2 ^ N a * T a

A branch whose yes side runs in time 2 ^ N times a polynomial runs in polynomial space and in time 2 ^ N times a polynomial, when the test and the no side are polynomial and the yes side has polynomial space. The yes time bound is needed only where condition holds. The polynomial factor T is left implicit, unlike the explicit constants of ExpTimePolySpace.