Documentation

CslibFrontier.Computability.Machines.Turing.MultiTape.Combinators.Encoding

Tidy computability in linear time and space #

Tidy computability (Turing.MultiTapeTM.ComputableTidilyInTimeAndSpace) is relative to encodings of values as words. Tidy computability in linear time and space is closed under case distinctions and concatenation of encoded values, and contains constant functions and the functions computed by finite-state transducers.

Main definitions #

Main results #

def Turing.MultiTapeTM.ComputableTidilyInLinearTimeAndSpace {α : Type u_1} {β : Type u_2} (f : α → β) (encIn : α ↪ List Bool) (encOut : β ↪ List Bool) :

f is tidily computable within a constant factor of the length of the encoded input plus one, in time and in space.

Instances For
    theorem Turing.MultiTapeTM.ComputableTidilyInTimeAndSpace.of_enc_eq {α : Type u_1} {β : Type u_2} {γ : Type u_3} {encIn : α ↪ List Bool} {encMid : β ↪ List Bool} {encOut : γ ↪ List Bool} {f : α → β} {g : α → γ} {t s : α → ℕ} (hf : ComputableTidilyInTimeAndSpace f encIn encMid t s) (h : ∀ (a : α), encOut (g a) = encMid (f a)) :

    Reuse the same machine when the new function emits the same encoded output word. The time and space bounds are unchanged; no encoding conversion is performed.

    Closure properties of linear time and space #

    theorem Turing.MultiTapeTM.ComputableTidilyInLinearTimeAndSpace.restrict {α : Type u_1} {β : Type u_2} {encIn : α ↪ List Bool} {encMid : β ↪ List Bool} {f : α → β} (h : ComputableTidilyInLinearTimeAndSpace f encIn encMid) (p : α → Prop) :

    A function tidily computable in linear time and space on all inputs is so on the inputs satisfying p.

    theorem Turing.MultiTapeTM.ComputableTidilyInLinearTimeAndSpace.ite {α : Type u_1} {β : Type u_2} {encIn : α ↪ List Bool} {encMid : β ↪ List Bool} {encC : Bool ↪ List Bool} {c : α → Bool} {f g : α → β} (hc : ComputableTidilyInLinearTimeAndSpace c encIn encC) (hf : ComputableTidilyInLinearTimeAndSpace (f ∘ Subtype.val) ((Function.Embedding.subtype fun (x : α) => c x = true).trans encIn) encMid) (hg : ComputableTidilyInLinearTimeAndSpace (g ∘ Subtype.val) ((Function.Embedding.subtype fun (x : α) => c x = false).trans encIn) encMid) :
    ComputableTidilyInLinearTimeAndSpace (fun (x : α) => if c x = true then f x else g x) encIn encMid

    Case distinctions of functions tidily computable in linear time and space, each branch on the inputs where it is taken.

    theorem Turing.MultiTapeTM.ComputableTidilyInLinearTimeAndSpace.const {α : Type u_1} {β : Type u_2} {encIn : α ↪ List Bool} {encMid : β ↪ List Bool} (b : β) :
    ComputableTidilyInLinearTimeAndSpace (fun (x : α) => b) encIn encMid

    Constant functions are tidily computable in linear time and space.

    theorem Turing.MultiTapeTM.ComputableTidilyInLinearTimeAndSpace.of_eq {α : Type u_1} {β : Type u_2} {encIn : α ↪ List Bool} {encMid : β ↪ List Bool} {f : α → β} (h : ∀ (a : α), encMid (f a) = encIn a) :

    Functions whose encoded value is the encoded input.

    theorem Turing.MultiTapeTM.ComputableTidilyInLinearTimeAndSpace.append {α : Type u_1} {β : Type u_2} {γ : Type u_3} {encIn : α ↪ List Bool} {encMid : β ↪ List Bool} {encOut : γ ↪ List Bool} {δ : Type u_4} {enc₂ : δ ↪ List Bool} {f₁ : α → β} {f₂ : α → δ} {g : α → γ} (h₁ : ComputableTidilyInLinearTimeAndSpace f₁ encIn encMid) (h₂ : ComputableTidilyInLinearTimeAndSpace f₂ encIn enc₂) (hg : ∀ (x : α), encOut (g x) = encMid (f₁ x) ++ enc₂ (f₂ x)) :

    A function whose encoded value is the concatenation of the encoded values of two functions tidily computable in linear time and space.

    theorem Turing.MultiTapeTM.Transducer.computableTidilyInLinearTimeAndSpace {Q : Type} [Finite Q] (τ : Transducer Bool Q) {α : Type u_1} {β : Type u_2} {encIn : α ↪ List Bool} {encOut : β ↪ List Bool} {f : α → β} (hf : ∀ (a : α), encOut (f a) = τ.run τ.q₀ (encIn a)) :

    A function computed by a transducer with finitely many states is tidily computable in linear time and space.