Computable functions #
This file contains the definition of a Turing machine with some finiteness conditions
(bundling the definition of TM2 in StackTuringMachine.lean), a definition of when a TM gives
a certain output (in a certain time), and the definition of computability (in polynomial time or
any time function) of a function between two types that have an encoding (as in Encoding.lean).
Main theorems #
idComputableInPolyTime: a TM + a proof it computes the identity on a type in polytime.idComputable: a TM + a proof it computes the identity on a type.
Implementation notes #
To count the execution time of a Turing machine, we have decided to count the number of times the
step function is used. Each step executes a statement (of type Stmt); this is a function, and
generally contains multiple "fundamental" steps (pushing, popping, and so on).
However, as functions only contain a finite number of executions and each one is executed at most
once, this execution time is up to multiplication by a constant the amount of fundamental steps.
A bundled TM2 (an equivalent of the classical Turing machine, defined starting from
the namespace Turing.TM2 in StackTuringMachine.lean), with an input and output stack,
a main function, an initial state and some finiteness guarantees.
- K : Type
index type of stacks
- kDecidableEq : DecidableEq self.K
A TM2 machine has finitely many stacks.
- k₀ : self.K
input resp. output stack
- k₁ : self.K
input resp. output stack
type of stack elements
- Λ : Type
type of function labels
- main : self.Λ
a main function: the initial function that is executed, given by its label
A TM2 machine has finitely many function labels.
- σ : Type
type of states of the machine
- initialState : self.σ
the initial state of the machine
a TM2 machine has finitely many internal states.
Each internal stack is finite.
the program itself, i.e. one function for every function label
Instances For
The type of statements (functions) corresponding to this TM.
Instances For
The type of configurations (functions) corresponding to this TM.
Instances For
The step function corresponding to this TM.
Instances For
The initial configuration corresponding to a list in the input alphabet.
Instances For
The final configuration corresponding to a list in the output alphabet.
Instances For
Alias of StateTransition.EvalsTo.
Instances For
Alias of StateTransition.EvalsToInTime.
Instances For
A proof of tm outputting l' when given l.
Instances For
The forgetful map, forgetting the upper bound on the number of steps.
Instances For
A (bundled TM2) Turing machine
with input alphabet equivalent to Γ₀ and output alphabet equivalent to Γ₁.
- tm : FinTM2
the underlying bundled TM2
the input alphabet is equivalent to
Γ₀the output alphabet is equivalent to
Γ₁
Instances For
A Turing machine + a proof it outputs f.
- outputsFun (a : α) : TM2Outputs self.tm (List.map self.inputAlphabet.invFun (ea a)) (some (List.map self.outputAlphabet.invFun (eb (f a))))
a proof this machine outputs
f
Instances For
A Turing machine + a time function +
a proof it outputs f in at most time(input.length) steps.
- time : ℕ → ℕ
a time function
- outputsFun (a : α) : TM2OutputsInTime self.tm (List.map self.inputAlphabet.invFun (ea a)) (some (List.map self.outputAlphabet.invFun (eb (f a)))) (self.time (ea a).length)
proof this machine outputs
fin at mosttime(input.length)steps
Instances For
A Turing machine + a polynomial time function +
a proof it outputs f in at most time(input.length) steps.
- time : Polynomial ℕ
a polynomial time function
- outputsFun (a : α) : TM2OutputsInTime self.tm (List.map self.inputAlphabet.invFun (ea a)) (some (List.map self.outputAlphabet.invFun (eb (f a)))) (Polynomial.eval (ea a).length self.time)
proof that this machine outputs
fin at mosttime(input.length)steps
Instances For
A forgetful map, forgetting the time bound on the number of steps.
Instances For
A forgetful map, forgetting that the time function is polynomial.
Instances For
A Turing machine computing the identity on α.
Instances For
A proof that the identity map on α is computable in polytime.
Instances For
A proof that the identity map on α is computable in time.
Instances For
A proof that the identity map on α is computable.