Case distinction #
If c, f and g are tidily computable from a common input, so is
fun x => if c x then f x else g x, within the bounds of c plus those of the branch taken.
iteTM tmc tm₁ tm₂ runs tmc with its output written to a new work tape, runs tm₁ if that word
is non-empty and tm₂ otherwise (Turing.MultiTapeTM.branch), and clears the tape. The condition
c may be computed with any encoding of Bool: a finite-state transducer turns its output into a
word that is empty exactly for false.
Main definitions #
Turing.MultiTapeTM.iteTM: the machine for a case distinction.
Main results #
Turing.MultiTapeTM.ComputesTidilyInTimeAndSpace.ite: the machine-level case distinction.Turing.MultiTapeTM.ComputableTidilyInTimeAndSpace.ite: case distinctions are tidily computable; each branch need only be computable on the inputs where it is taken.
Run tmc with its output on a new last work tape, then tm₁ if that word is non-empty and
tm₂ otherwise, and clear the tape. All three machines are padded to max k₀ (max k₁ k₂) work
tapes.
Instances For
If tmc computes w from x tidily, tm₁ computes y from x tidily when w is non-empty
and tm₂ does when w is empty, then iteTM tmc tm₁ tm₂ computes y from x tidily, within the
bounds of tmc plus those of the machine that runs.
A function tidily computable on all inputs is tidily computable on the inputs satisfying p, by
the same machine.
Case distinctions are tidily computable: if c is tidily computable, f on the inputs where
c holds and g on the others, then fun x => if c x then f x else g x is tidily computable,
within the bounds of c plus those of the branch taken, up to a constant. The condition may be
computed with any encoding of Bool.