Complexity of Almost Constant Functions #
A function f : α → β that is constant except for a finite number of arguments is computable in
constant time and zero space: the machine reads the encoded input while remembering the prefix it
has seen so far. After a finite number of steps it either reaches the end of the input or a point
where the prefix cannot be extended to the encoding of one of the finitely many exceptions. In both
cases, it emits the corresponding output one symbol at a time.
This result also holds for functions whose domain is already finite.
Main Results #
encodedComputableInTimeAndSpace_of_finite: Every function on a finite type is computable in constant time and zero space, relative to any encoding.encodedComputableInTimeAndSpace_of_exists_finite_ne: Every function that is constant except for a finite number of arguments is computable in constant time and zero space, relative to any encoding.encodedComputableInTimeAndSpace_of_const: Every constant function is computable in constant time and zero space, relative to any encoding.encodedComputableInTimeAndSpace_almostConstTimeandencodedComputableInTimeAndSpace_finiteFunTime: The same with explicit time bounds.
The machine computing a function that is constant outside a finite set #
The machine almostConstTM encIn encOut f S out computes f, provided that the encoded output
of f is the fixed Boolean string out outside of the finite set S.
Every function whose encoded output is constant outside of a finite set is computable in time
almostConstTime and zero space.
Every almost constant function is computable in constant time and zero space.
Every constant function is computable in constant time and zero space.
A constant time bound for functions on a finite type.
Equations
- Turing.MultiTapeTM.finiteFunTime encIn encOut f = Turing.MultiTapeTM.almostConstTime encIn encOut f Finset.univ []
Instances For
Every function on a finite type is computable in time finiteFunTime and zero space.
Every function on a finite type is computable in constant time and zero space.