Documentation

CslibFrontier.Computability.Machines.Turing.MultiTape.Complexity.InSpace.Context

Stored registers next to a read-only input, within a fixed workspace budget #

A body of Turing.MultiTapeTM.ComputableInSpace.loopWith or Turing.MultiTapeTM.ComputableInSpace.recWith is a function of a pair (r, a) of stored registers and the input, encoded by encPair encR encA, within a budget that charges the registers and not the input. The rules of this module are the leaves of such a certificate, in the budget-preserving form of Turing.MultiTapeTM.ComputableInSpace.budget_prod, so that space composes the rest: the registers, a function of the input alone, a certified function of other registers, the length of the input, and the bit of the input at a computed position.

Every rule asks that the budget cover the registers and the logarithm of the length of the input, as the hypothesis (fun p => (encR p.1).length + Nat.log2 (encA p.2).length) ≼ Bs. For a budget that is a sum with these two summands, space proves it.

Main results #

@[reducible, inline]
abbrev Turing.MultiTapeTM.ComputableInSpace.CoversContext {α ρ : Type} (encR : ρ ↪ List Bool) (encA : α ↪ List Bool) (Bs : ρ × α → ℕ) :

The budget Bs covers the registers and the logarithm of the length of the input.

theorem Turing.MultiTapeTM.ComputableInSpace.budget_registers {α ρ : Type} {encA : α ↪ List Bool} {encR : ρ ↪ List Bool} {Bs : ρ × α → ℕ} (h : CoversContext encR encA Bs) :
ComputableInSpace (fun (p : ρ × α) => p.1) (encPair encR encA) encR Bs

The stored registers, within a budget that covers them.

theorem Turing.MultiTapeTM.ComputableInSpace.budget_ofInput {α ρ β : Type} {encA : α ↪ List Bool} {encR : ρ ↪ List Bool} {encB : β ↪ List Bool} {Bs : ρ × α → ℕ} {f : α → β} {S : α → ℕ} (hf : ComputableInSpace f encA encB S) (h : CoversContext encR encA Bs) (hS : BigOLe (fun (p : ρ × α) => S p.2) Bs) :
ComputableInSpace (fun (p : ρ × α) => f p.2) (encPair encR encA) encB Bs

A function of the input alone next to stored registers: within a budget that covers the registers and the budget of the function.

theorem Turing.MultiTapeTM.ComputableInSpace.budget_subst {α ρ σ γ : Type} {encA : α ↪ List Bool} {encR : ρ ↪ List Bool} {encS : σ ↪ List Bool} {encC : γ ↪ List Bool} {Bs : ρ × α → ℕ} {g : σ × α → γ} {T : σ × α → ℕ} {f : ρ × α → σ} (hg : ComputableInSpace g (encPair encS encA) encC T) (hf : ComputableInLogSpace f (encPair encR encA) encS) (h : CoversContext encR encA Bs) (hT : BigOLe (fun (p : ρ × α) => T (f p, p.2)) Bs) :
ComputableInSpace (fun (p : ρ × α) => g (f p, p.2)) (encPair encR encA) encC Bs

A certified function of registers and the input, on registers that a logspace map computes from the stored ones: within a budget that covers the stored registers and the budget of the function on the new ones. The new registers are recomputed, not stored.

theorem Turing.MultiTapeTM.ComputableInSpace.assoc_context {α ρ σ γ : Type} {encA : α ↪ List Bool} {encR : ρ ↪ List Bool} {encS : σ ↪ List Bool} {encC : γ ↪ List Bool} {g : (σ × ρ) × α → γ} {T : (σ × ρ) × α → ℕ} (hg : ComputableInSpace g (encPair (encPair encS encR) encA) encC T) :
ComputableInSpace (fun (q : σ × ρ × α) => g ((q.1, q.2.1), q.2.2)) (encPair encS (encPair encR encA)) encC fun (q : σ × ρ × α) => T ((q.1, q.2.1), q.2.2) + (encS q.1).length + (encR q.2.1).length + (encA q.2.2).length.log2

Registers next to the registers of an enclosing rule. A function of registers (s, r) and the input is also a function of the registers s and the context (r, a), in which the outer registers r and the input are read-only. This is the form in which a rule such as Turing.MultiTapeTM.ComputableInSpace.recWith asks for a part when the rule is itself applied to stored registers and an input.

theorem Turing.MultiTapeTM.ComputableInSpace.inputLength {α : Type} (encA : α ↪ List Bool) :
ComputableInSpace (fun (a : α) => (encA a).length) encA encNat fun (a : α) => (encA a).length.log2

The length of the input, in binary, within the logarithm of that length.

theorem Turing.MultiTapeTM.ComputableInSpace.budget_inputLength {α ρ : Type} {encA : α ↪ List Bool} {encR : ρ ↪ List Bool} {Bs : ρ × α → ℕ} (h : CoversContext encR encA Bs) :
ComputableInSpace (fun (p : ρ × α) => (encA p.2).length) (encPair encR encA) encNat Bs

The length of the input next to stored registers, within a budget that covers them.

theorem Turing.MultiTapeTM.ComputableInSpace.budget_inputBit {α ρ : Type} {encA : α ↪ List Bool} {encR : ρ ↪ List Bool} {Bs i : ρ × α → ℕ} (hi : ComputableInSpace i (encPair encR encA) encNat Bs) (h : CoversContext encR encA Bs) :
ComputableInSpace (fun (p : ρ × α) => (encA p.2)[i p]?) (encPair encR encA) (encOption encBool) Bs

The bit of the input at a computed position, none past its end: the position is any function of the registers and the input within the budget; it is stored, and the input is read there (Turing.MultiTapeTM.ComputableInSpace.bindWith, Turing.MultiTapeTM.ComputableInSpace.inputBit).