Case analysis within linear work space #
Case analysis on a tagged sum or option preserves space linear in the encoded input. The implementations reuse the native case combinators, forgetting their time bounds.
theorem Turing.MultiTapeTM.ComputableInSpace.sumElimSnd {π α β ε : Type} {encP : π ↪ List Bool} {encA : α ↪ List Bool} {encB : β ↪ List Bool} {encE : ε ↪ List Bool} {f : π × α → ε} {g : π × β → ε} (hf : ComputableInSpace f (encPair encP encA) encE fun (p : π × α) => ((encPair encP encA) p).length) (hg : ComputableInSpace g (encPair encP encB) encE fun (p : π × β) => ((encPair encP encB) p).length) :
Linear-space branches give linear-space case analysis on the second component.
theorem Turing.MultiTapeTM.ComputableInSpace.optionElimSnd {π α ε : Type} {encP : π ↪ List Bool} {encA : α ↪ List Bool} {encE : ε ↪ List Bool} {f : π → ε} {g : π × α → ε} (hf : ComputableInSpace f encP encE fun (p : π) => (encP p).length) (hg : ComputableInSpace g (encPair encP encA) encE fun (p : π × α) => ((encPair encP encA) p).length) :
Inspecting an option and running its selected linear-space branch uses linear space.
theorem Turing.MultiTapeTM.ComputableInSpace.optionElim {α ε : Type} {encA : α ↪ List Bool} {encE : ε ↪ List Bool} (fallback : ε) {g : α → ε} (hg : ComputableInSpace g encA encE fun (a : α) => (encA a).length) :
Linear-space case analysis on an option without an auxiliary parameter.
theorem Turing.MultiTapeTM.ComputableInSpace.sumElimFst {π α β ε : Type} {encP : π ↪ List Bool} {encA : α ↪ List Bool} {encB : β ↪ List Bool} {encE : ε ↪ List Bool} {f : α × π → ε} {g : β × π → ε} (hf : ComputableInSpace f (encPair encA encP) encE fun (p : α × π) => ((encPair encA encP) p).length) (hg : ComputableInSpace g (encPair encB encP) encE fun (p : β × π) => ((encPair encB encP) p).length) :
Case analysis on the first component preserves a shared second parameter.
theorem Turing.MultiTapeTM.ComputableInSpace.sumElim {α β ε : Type} {encA : α ↪ List Bool} {encB : β ↪ List Bool} {encE : ε ↪ List Bool} {f : α → ε} {g : β → ε} (hf : ComputableInSpace f encA encE fun (a : α) => (encA a).length) (hg : ComputableInSpace g encB encE fun (b : β) => (encB b).length) :
Linear-space case analysis without an auxiliary parameter.