The Mathlib Handbook

The volumes of the handbook are not written yet. This site shows the map of Mathlib that they will follow, at Mathlib 4472534b60.

The areas / V32. Logic, model theory and computability

Mathlib.Computability.TuringMachine.Computable

77 declarations. Mathlib docs · Source

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.

theorem Turing.TM2ComputableInPolyTime.mk.injEq E0 #

∀ {α β αΓ βΓ : Type} {ea : α → List αΓ} {eb : β → List βΓ} {f : α → β}
  (toTM2ComputableAux : Turing.TM2ComputableAux αΓ βΓ) (time : Polynomial ℕ)
  (outputsFun :
    (a : α) →
      Turing.TM2OutputsInTime toTM2ComputableAux.tm (List.map toTM2ComputableAux.inputAlphabet.invFun (ea a))
        (some (List.map toTM2ComputableAux.outputAlphabet.invFun (eb (f a)))) (Polynomial.eval (ea a).length time))
  (toTM2ComputableAux_1 : Turing.TM2ComputableAux αΓ βΓ) (time_1 : Polynomial ℕ)
  (outputsFun_1 :
    (a : α) →
      Turing.TM2OutputsInTime toTM2ComputableAux_1.tm (List.map toTM2ComputableAux_1.inputAlphabet.invFun (ea a))
        (some (List.map toTM2ComputableAux_1.outputAlphabet.invFun (eb (f a)))) (Polynomial.eval (ea a).length time_1)),
  ({ toTM2ComputableAux := toTM2ComputableAux, time := time, outputsFun := outputsFun } =
      { toTM2ComputableAux := toTM2ComputableAux_1, time := time_1, outputsFun := outputsFun_1 }) =
    (toTM2ComputableAux = toTM2ComputableAux_1 ∧ time = time_1 ∧ outputsFun ≍ outputsFun_1)

def Turing.TM2ComputableInTime.ctorIdx E1 #

{α β αΓ βΓ : Type} → {ea : α → List αΓ} → {eb : β → List βΓ} → {f : α → β} → Turing.TM2ComputableInTime ea eb f → ℕ

theorem Turing.FinTM2.mk.injEq E0 #

∀ {K : Type} [kDecidableEq : DecidableEq K] [kFin : Fintype K] (k₀ k₁ : K) (Γ : K → Type) (Λ : Type) (main : Λ)
  [ΛFin : Fintype Λ] (σ : Type) (initialState : σ) [σFin : Fintype σ] [Γk₀Fin : Fintype (Γ k₀)]
  (m : Λ → Turing.TM2.Stmt Γ Λ σ) (K_1 : Type) (kDecidableEq_1 : DecidableEq K_1) (kFin_1 : Fintype K_1)
  (k₀_1 k₁_1 : K_1) (Γ_1 : K_1 → Type) (Λ_1 : Type) (main_1 : Λ_1) (ΛFin_1 : Fintype Λ_1) (σ_1 : Type)
  (initialState_1 : σ_1) (σFin_1 : Fintype σ_1) (Γk₀Fin_1 : Fintype (Γ_1 k₀_1))
  (m_1 : Λ_1 → Turing.TM2.Stmt Γ_1 Λ_1 σ_1),
  ({ K := K, kDecidableEq := kDecidableEq, kFin := kFin, k₀ := k₀, k₁ := k₁, Γ := Γ, Λ := Λ, main := main, ΛFin := ΛFin,
        σ := σ, initialState := initialState, σFin := σFin, Γk₀Fin := Γk₀Fin, m := m } =
      { K := K_1, kDecidableEq := kDecidableEq_1, kFin := kFin_1, k₀ := k₀_1, k₁ := k₁_1, Γ := Γ_1, Λ := Λ_1,
        main := main_1, ΛFin := ΛFin_1, σ := σ_1, initialState := initialState_1, σFin := σFin_1, Γk₀Fin := Γk₀Fin_1,
        m := m_1 }) =
    (K = K_1 ∧
      kDecidableEq ≍ kDecidableEq_1 ∧
        kFin ≍ kFin_1 ∧
          k₀ ≍ k₀_1 ∧
            k₁ ≍ k₁_1 ∧
              Γ ≍ Γ_1 ∧
                Λ = Λ_1 ∧
                  main ≍ main_1 ∧
                    ΛFin ≍ ΛFin_1 ∧
                      σ = σ_1 ∧ initialState ≍ initialState_1 ∧ σFin ≍ σFin_1 ∧ Γk₀Fin ≍ Γk₀Fin_1 ∧ m ≍ m_1)

def Turing.TM2Computable.ctorIdx E1 #

{α β αΓ βΓ : Type} → {ea : α → List αΓ} → {eb : β → List βΓ} → {f : α → β} → Turing.TM2Computable ea eb f → ℕ

theorem Turing.TM2ComputableInTime.mk.inj E1 #

∀ {α β αΓ βΓ : Type} {ea : α → List αΓ} {eb : β → List βΓ} {f : α → β}
  {toTM2ComputableAux : Turing.TM2ComputableAux αΓ βΓ} {time : ℕ → ℕ}
  {outputsFun :
    (a : α) →
      Turing.TM2OutputsInTime toTM2ComputableAux.tm (List.map toTM2ComputableAux.inputAlphabet.invFun (ea a))
        (some (List.map toTM2ComputableAux.outputAlphabet.invFun (eb (f a)))) (time (ea a).length)}
  {toTM2ComputableAux_1 : Turing.TM2ComputableAux αΓ βΓ} {time_1 : ℕ → ℕ}
  {outputsFun_1 :
    (a : α) →
      Turing.TM2OutputsInTime toTM2ComputableAux_1.tm (List.map toTM2ComputableAux_1.inputAlphabet.invFun (ea a))
        (some (List.map toTM2ComputableAux_1.outputAlphabet.invFun (eb (f a)))) (time_1 (ea a).length)},
  { toTM2ComputableAux := toTM2ComputableAux, time := time, outputsFun := outputsFun } =
      { toTM2ComputableAux := toTM2ComputableAux_1, time := time_1, outputsFun := outputsFun_1 } →
    toTM2ComputableAux = toTM2ComputableAux_1 ∧ time = time_1 ∧ outputsFun ≍ outputsFun_1

theorem Turing.FinTM2.mk.inj E1 #

∀ {K : Type} {kDecidableEq : DecidableEq K} {kFin : Fintype K} {k₀ k₁ : K} {Γ : K → Type} {Λ : Type} {main : Λ}
  {ΛFin : Fintype Λ} {σ : Type} {initialState : σ} {σFin : Fintype σ} {Γk₀Fin : Fintype (Γ k₀)}
  {m : Λ → Turing.TM2.Stmt Γ Λ σ} {K_1 : Type} {kDecidableEq_1 : DecidableEq K_1} {kFin_1 : Fintype K_1}
  {k₀_1 k₁_1 : K_1} {Γ_1 : K_1 → Type} {Λ_1 : Type} {main_1 : Λ_1} {ΛFin_1 : Fintype Λ_1} {σ_1 : Type}
  {initialState_1 : σ_1} {σFin_1 : Fintype σ_1} {Γk₀Fin_1 : Fintype (Γ_1 k₀_1)}
  {m_1 : Λ_1 → Turing.TM2.Stmt Γ_1 Λ_1 σ_1},
  { K := K, kDecidableEq := kDecidableEq, kFin := kFin, k₀ := k₀, k₁ := k₁, Γ := Γ, Λ := Λ, main := main, ΛFin := ΛFin,
        σ := σ, initialState := initialState, σFin := σFin, Γk₀Fin := Γk₀Fin, m := m } =
      { K := K_1, kDecidableEq := kDecidableEq_1, kFin := kFin_1, k₀ := k₀_1, k₁ := k₁_1, Γ := Γ_1, Λ := Λ_1,
        main := main_1, ΛFin := ΛFin_1, σ := σ_1, initialState := initialState_1, σFin := σFin_1, Γk₀Fin := Γk₀Fin_1,
        m := m_1 } →
    K = K_1 ∧
      kDecidableEq ≍ kDecidableEq_1 ∧
        kFin ≍ kFin_1 ∧
          k₀ ≍ k₀_1 ∧
            k₁ ≍ k₁_1 ∧
              Γ ≍ Γ_1 ∧
                Λ = Λ_1 ∧
                  main ≍ main_1 ∧
                    ΛFin ≍ ΛFin_1 ∧
                      σ = σ_1 ∧ initialState ≍ initialState_1 ∧ σFin ≍ σFin_1 ∧ Γk₀Fin ≍ Γk₀Fin_1 ∧ m ≍ m_1

theorem Turing.TM2ComputableAux.mk.inj E1 #

∀ {Γ₀ Γ₁ : Type} {tm : Turing.FinTM2} {inputAlphabet : tm.Γ tm.k₀ ≃ Γ₀} {outputAlphabet : tm.Γ tm.k₁ ≃ Γ₁}
  {tm_1 : Turing.FinTM2} {inputAlphabet_1 : tm_1.Γ tm_1.k₀ ≃ Γ₀} {outputAlphabet_1 : tm_1.Γ tm_1.k₁ ≃ Γ₁},
  { tm := tm, inputAlphabet := inputAlphabet, outputAlphabet := outputAlphabet } =
      { tm := tm_1, inputAlphabet := inputAlphabet_1, outputAlphabet := outputAlphabet_1 } →
    tm = tm_1 ∧ inputAlphabet ≍ inputAlphabet_1 ∧ outputAlphabet ≍ outputAlphabet_1

def Turing.TM2ComputableAux.ctorIdx E1 #

{Γ₀ Γ₁ : Type} → Turing.TM2ComputableAux Γ₀ Γ₁ → ℕ

def Turing.FinTM2.ctorIdx E1 #

Turing.FinTM2 → ℕ

theorem Turing.TM2ComputableInTime.mk.injEq E0 #

∀ {α β αΓ βΓ : Type} {ea : α → List αΓ} {eb : β → List βΓ} {f : α → β}
  (toTM2ComputableAux : Turing.TM2ComputableAux αΓ βΓ) (time : ℕ → ℕ)
  (outputsFun :
    (a : α) →
      Turing.TM2OutputsInTime toTM2ComputableAux.tm (List.map toTM2ComputableAux.inputAlphabet.invFun (ea a))
        (some (List.map toTM2ComputableAux.outputAlphabet.invFun (eb (f a)))) (time (ea a).length))
  (toTM2ComputableAux_1 : Turing.TM2ComputableAux αΓ βΓ) (time_1 : ℕ → ℕ)
  (outputsFun_1 :
    (a : α) →
      Turing.TM2OutputsInTime toTM2ComputableAux_1.tm (List.map toTM2ComputableAux_1.inputAlphabet.invFun (ea a))
        (some (List.map toTM2ComputableAux_1.outputAlphabet.invFun (eb (f a)))) (time_1 (ea a).length)),
  ({ toTM2ComputableAux := toTM2ComputableAux, time := time, outputsFun := outputsFun } =
      { toTM2ComputableAux := toTM2ComputableAux_1, time := time_1, outputsFun := outputsFun_1 }) =
    (toTM2ComputableAux = toTM2ComputableAux_1 ∧ time = time_1 ∧ outputsFun ≍ outputsFun_1)

theorem Turing.TM2ComputableInPolyTime.mk.inj E1 #

∀ {α β αΓ βΓ : Type} {ea : α → List αΓ} {eb : β → List βΓ} {f : α → β}
  {toTM2ComputableAux : Turing.TM2ComputableAux αΓ βΓ} {time : Polynomial ℕ}
  {outputsFun :
    (a : α) →
      Turing.TM2OutputsInTime toTM2ComputableAux.tm (List.map toTM2ComputableAux.inputAlphabet.invFun (ea a))
        (some (List.map toTM2ComputableAux.outputAlphabet.invFun (eb (f a)))) (Polynomial.eval (ea a).length time)}
  {toTM2ComputableAux_1 : Turing.TM2ComputableAux αΓ βΓ} {time_1 : Polynomial ℕ}
  {outputsFun_1 :
    (a : α) →
      Turing.TM2OutputsInTime toTM2ComputableAux_1.tm (List.map toTM2ComputableAux_1.inputAlphabet.invFun (ea a))
        (some (List.map toTM2ComputableAux_1.outputAlphabet.invFun (eb (f a)))) (Polynomial.eval (ea a).length time_1)},
  { toTM2ComputableAux := toTM2ComputableAux, time := time, outputsFun := outputsFun } =
      { toTM2ComputableAux := toTM2ComputableAux_1, time := time_1, outputsFun := outputsFun_1 } →
    toTM2ComputableAux = toTM2ComputableAux_1 ∧ time = time_1 ∧ outputsFun ≍ outputsFun_1

theorem Turing.TM2Computable.mk.inj E1 #

∀ {α β αΓ βΓ : Type} {ea : α → List αΓ} {eb : β → List βΓ} {f : α → β}
  {toTM2ComputableAux : Turing.TM2ComputableAux αΓ βΓ}
  {outputsFun :
    (a : α) →
      Turing.TM2Outputs toTM2ComputableAux.tm (List.map toTM2ComputableAux.inputAlphabet.invFun (ea a))
        (some (List.map toTM2ComputableAux.outputAlphabet.invFun (eb (f a))))}
  {toTM2ComputableAux_1 : Turing.TM2ComputableAux αΓ βΓ}
  {outputsFun_1 :
    (a : α) →
      Turing.TM2Outputs toTM2ComputableAux_1.tm (List.map toTM2ComputableAux_1.inputAlphabet.invFun (ea a))
        (some (List.map toTM2ComputableAux_1.outputAlphabet.invFun (eb (f a))))},
  { toTM2ComputableAux := toTM2ComputableAux, outputsFun := outputsFun } =
      { toTM2ComputableAux := toTM2ComputableAux_1, outputsFun := outputsFun_1 } →
    toTM2ComputableAux = toTM2ComputableAux_1 ∧ outputsFun ≍ outputsFun_1

theorem Turing.TM2Computable.mk.injEq E0 #

∀ {α β αΓ βΓ : Type} {ea : α → List αΓ} {eb : β → List βΓ} {f : α → β}
  (toTM2ComputableAux : Turing.TM2ComputableAux αΓ βΓ)
  (outputsFun :
    (a : α) →
      Turing.TM2Outputs toTM2ComputableAux.tm (List.map toTM2ComputableAux.inputAlphabet.invFun (ea a))
        (some (List.map toTM2ComputableAux.outputAlphabet.invFun (eb (f a)))))
  (toTM2ComputableAux_1 : Turing.TM2ComputableAux αΓ βΓ)
  (outputsFun_1 :
    (a : α) →
      Turing.TM2Outputs toTM2ComputableAux_1.tm (List.map toTM2ComputableAux_1.inputAlphabet.invFun (ea a))
        (some (List.map toTM2ComputableAux_1.outputAlphabet.invFun (eb (f a))))),
  ({ toTM2ComputableAux := toTM2ComputableAux, outputsFun := outputsFun } =
      { toTM2ComputableAux := toTM2ComputableAux_1, outputsFun := outputsFun_1 }) =
    (toTM2ComputableAux = toTM2ComputableAux_1 ∧ outputsFun ≍ outputsFun_1)

theorem Turing.TM2ComputableAux.mk.injEq E0 #

∀ {Γ₀ Γ₁ : Type} (tm : Turing.FinTM2) (inputAlphabet : tm.Γ tm.k₀ ≃ Γ₀) (outputAlphabet : tm.Γ tm.k₁ ≃ Γ₁)
  (tm_1 : Turing.FinTM2) (inputAlphabet_1 : tm_1.Γ tm_1.k₀ ≃ Γ₀) (outputAlphabet_1 : tm_1.Γ tm_1.k₁ ≃ Γ₁),
  ({ tm := tm, inputAlphabet := inputAlphabet, outputAlphabet := outputAlphabet } =
      { tm := tm_1, inputAlphabet := inputAlphabet_1, outputAlphabet := outputAlphabet_1 }) =
    (tm = tm_1 ∧ inputAlphabet ≍ inputAlphabet_1 ∧ outputAlphabet ≍ outputAlphabet_1)

def Turing.TM2ComputableInPolyTime.ctorIdx E1 #

{α β αΓ βΓ : Type} → {ea : α → List αΓ} → {eb : β → List βΓ} → {f : α → β} → Turing.TM2ComputableInPolyTime ea eb f → ℕ

structure Turing.FinTM2 E1 #

Type 1

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.

ctor Turing.FinTM2.mk E0 #

{K : Type} →
  [kDecidableEq : DecidableEq K] →
    [kFin : Fintype K] →
      (k₀ : K) →
        K →
          (Γ : K → Type) →
            (Λ : Type) →
              Λ →
                [ΛFin : Fintype Λ] →
                  (σ : Type) →
                    σ → [σFin : Fintype σ] → [Γk₀Fin : Fintype (Γ k₀)] → (Λ → Turing.TM2.Stmt Γ Λ σ) → Turing.FinTM2

abbrev Turing.FinTM2.K E1 #

Turing.FinTM2 → Type

index type of stacks

abbrev Turing.FinTM2.kDecidableEq E1 #

(self : Turing.FinTM2) → DecidableEq self.K

abbrev Turing.FinTM2.kFin E1 #

(self : Turing.FinTM2) → Fintype self.K

A TM2 machine has finitely many stacks.

abbrev Turing.FinTM2.k₀ E1 #

(self : Turing.FinTM2) → self.K

input resp. output stack

abbrev Turing.FinTM2.k₁ E1 #

(self : Turing.FinTM2) → self.K

input resp. output stack

abbrev Turing.FinTM2.Γ E1 #

(self : Turing.FinTM2) → self.K → Type

type of stack elements

abbrev Turing.FinTM2.Λ E1 #

Turing.FinTM2 → Type

type of function labels

abbrev Turing.FinTM2.main E1 #

(self : Turing.FinTM2) → self.Λ

a main function: the initial function that is executed, given by its label

abbrev Turing.FinTM2.ΛFin E1 #

(self : Turing.FinTM2) → Fintype self.Λ

A TM2 machine has finitely many function labels.

abbrev Turing.FinTM2.σ E1 #

Turing.FinTM2 → Type

type of states of the machine

abbrev Turing.FinTM2.initialState E1 #

(self : Turing.FinTM2) → self.σ

the initial state of the machine

abbrev Turing.FinTM2.σFin E1 #

(self : Turing.FinTM2) → Fintype self.σ

a TM2 machine has finitely many internal states.

abbrev Turing.FinTM2.Γk₀Fin E1 #

(self : Turing.FinTM2) → Fintype (self.Γ self.k₀)

Each internal stack is finite.

abbrev Turing.FinTM2.m E1 #

(self : Turing.FinTM2) → self.Λ → Turing.TM2.Stmt self.Γ self.Λ self.σ

the program itself, i.e. one function for every function label

instance Turing.FinTM2.decidableEqK E0 #

(tm : Turing.FinTM2) → DecidableEq tm.K

instance Turing.FinTM2.inhabitedσ E0 #

(tm : Turing.FinTM2) → Inhabited tm.σ

def Turing.FinTM2.Stmt E1 #

Turing.FinTM2 → Type

The type of statements (functions) corresponding to this TM.

instance Turing.FinTM2.inhabitedStmt E0 #

(tm : Turing.FinTM2) → Inhabited tm.Stmt

def Turing.FinTM2.Cfg E1 #

Turing.FinTM2 → Type

The type of configurations (functions) corresponding to this TM.

instance Turing.FinTM2.inhabitedCfg E0 #

(tm : Turing.FinTM2) → Inhabited tm.Cfg

def Turing.FinTM2.step E1 #

(tm : Turing.FinTM2) → tm.Cfg → Option tm.Cfg

The step function corresponding to this TM.

def Turing.initList E1 #

(tm : Turing.FinTM2) → List (tm.Γ tm.k₀) → tm.Cfg

The initial configuration corresponding to a list in the input alphabet.

def Turing.haltList E1 #

(tm : Turing.FinTM2) → List (tm.Γ tm.k₁) → tm.Cfg

The final configuration corresponding to a list in the output alphabet.

def Turing.TM2Outputs E1 #

(tm : Turing.FinTM2) → List (tm.Γ tm.k₀) → Option (List (tm.Γ tm.k₁)) → Type

A proof of tm outputting l' when given l.

def Turing.TM2OutputsInTime E1 #

(tm : Turing.FinTM2) → List (tm.Γ tm.k₀) → Option (List (tm.Γ tm.k₁)) → ℕ → Type

A proof of tm outputting l' when given l in at most m steps.

def Turing.TM2OutputsInTime.toTM2Outputs E1 #

{tm : Turing.FinTM2} →
  {l : List (tm.Γ tm.k₀)} →
    {l' : Option (List (tm.Γ tm.k₁))} → {m : ℕ} → Turing.TM2OutputsInTime tm l l' m → Turing.TM2Outputs tm l l'

The forgetful map, forgetting the upper bound on the number of steps.

structure Turing.TM2ComputableAux E0 #

Type → Type → Type 1

A (bundled TM2) Turing machine with input alphabet equivalent to Γ₀ and output alphabet equivalent to Γ₁.

ctor Turing.TM2ComputableAux.mk E0 #

{Γ₀ Γ₁ : Type} → (tm : Turing.FinTM2) → tm.Γ tm.k₀ ≃ Γ₀ → tm.Γ tm.k₁ ≃ Γ₁ → Turing.TM2ComputableAux Γ₀ Γ₁

abbrev Turing.TM2ComputableAux.tm E1 #

{Γ₀ Γ₁ : Type} → Turing.TM2ComputableAux Γ₀ Γ₁ → Turing.FinTM2

the underlying bundled TM2

abbrev Turing.TM2ComputableAux.inputAlphabet E1 #

{Γ₀ Γ₁ : Type} → (self : Turing.TM2ComputableAux Γ₀ Γ₁) → self.tm.Γ self.tm.k₀ ≃ Γ₀

the input alphabet is equivalent to Γ₀

abbrev Turing.TM2ComputableAux.outputAlphabet E1 #

{Γ₀ Γ₁ : Type} → (self : Turing.TM2ComputableAux Γ₀ Γ₁) → self.tm.Γ self.tm.k₁ ≃ Γ₁

the output alphabet is equivalent to Γ₁

structure Turing.TM2Computable E3 #

{α β αΓ βΓ : Type} → (α → List αΓ) → (β → List βΓ) → (α → β) → Type 1

A Turing machine + a proof it outputs f.

abbrev Turing.TM2Computable.toTM2ComputableAux E0 #

{α β αΓ βΓ : Type} →
  {ea : α → List αΓ} → {eb : β → List βΓ} → {f : α → β} → Turing.TM2Computable ea eb f → Turing.TM2ComputableAux αΓ βΓ

ctor Turing.TM2Computable.mk E0 #

{α β αΓ βΓ : Type} →
  {ea : α → List αΓ} →
    {eb : β → List βΓ} →
      {f : α → β} →
        (toTM2ComputableAux : Turing.TM2ComputableAux αΓ βΓ) →
          ((a : α) →
              Turing.TM2Outputs toTM2ComputableAux.tm (List.map toTM2ComputableAux.inputAlphabet.invFun (ea a))
                (some (List.map toTM2ComputableAux.outputAlphabet.invFun (eb (f a))))) →
            Turing.TM2Computable ea eb f

abbrev Turing.TM2Computable.outputsFun E1 #

{α β αΓ βΓ : Type} →
  {ea : α → List αΓ} →
    {eb : β → List βΓ} →
      {f : α → β} →
        (self : Turing.TM2Computable ea eb f) →
          (a : α) →
            Turing.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

structure Turing.TM2ComputableInTime E1 #

{α β αΓ βΓ : Type} → (α → List αΓ) → (β → List βΓ) → (α → β) → Type 1

A Turing machine + a time function + a proof it outputs f in at most time(input.length) steps.

abbrev Turing.TM2ComputableInTime.toTM2ComputableAux E0 #

{α β αΓ βΓ : Type} →
  {ea : α → List αΓ} →
    {eb : β → List βΓ} → {f : α → β} → Turing.TM2ComputableInTime ea eb f → Turing.TM2ComputableAux αΓ βΓ

ctor Turing.TM2ComputableInTime.mk E0 #

{α β αΓ βΓ : Type} →
  {ea : α → List αΓ} →
    {eb : β → List βΓ} →
      {f : α → β} →
        (toTM2ComputableAux : Turing.TM2ComputableAux αΓ βΓ) →
          (time : ℕ → ℕ) →
            ((a : α) →
                Turing.TM2OutputsInTime toTM2ComputableAux.tm (List.map toTM2ComputableAux.inputAlphabet.invFun (ea a))
                  (some (List.map toTM2ComputableAux.outputAlphabet.invFun (eb (f a)))) (time (ea a).length)) →
              Turing.TM2ComputableInTime ea eb f

abbrev Turing.TM2ComputableInTime.time E1 #

{α β αΓ βΓ : Type} → {ea : α → List αΓ} → {eb : β → List βΓ} → {f : α → β} → Turing.TM2ComputableInTime ea eb f → ℕ → ℕ

a time function

abbrev Turing.TM2ComputableInTime.outputsFun E1 #

{α β αΓ βΓ : Type} →
  {ea : α → List αΓ} →
    {eb : β → List βΓ} →
      {f : α → β} →
        (self : Turing.TM2ComputableInTime ea eb f) →
          (a : α) →
            Turing.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 f in at most time(input.length) steps

structure Turing.TM2ComputableInPolyTime E3 #

{α β αΓ βΓ : Type} → (α → List αΓ) → (β → List βΓ) → (α → β) → Type 1

A Turing machine + a polynomial time function + a proof it outputs f in at most time(input.length) steps.

abbrev Turing.TM2ComputableInPolyTime.toTM2ComputableAux E0 #

{α β αΓ βΓ : Type} →
  {ea : α → List αΓ} →
    {eb : β → List βΓ} → {f : α → β} → Turing.TM2ComputableInPolyTime ea eb f → Turing.TM2ComputableAux αΓ βΓ

ctor Turing.TM2ComputableInPolyTime.mk E0 #

{α β αΓ βΓ : Type} →
  {ea : α → List αΓ} →
    {eb : β → List βΓ} →
      {f : α → β} →
        (toTM2ComputableAux : Turing.TM2ComputableAux αΓ βΓ) →
          (time : Polynomial ℕ) →
            ((a : α) →
                Turing.TM2OutputsInTime toTM2ComputableAux.tm (List.map toTM2ComputableAux.inputAlphabet.invFun (ea a))
                  (some (List.map toTM2ComputableAux.outputAlphabet.invFun (eb (f a))))
                  (Polynomial.eval (ea a).length time)) →
              Turing.TM2ComputableInPolyTime ea eb f

abbrev Turing.TM2ComputableInPolyTime.time E1 #

{α β αΓ βΓ : Type} →
  {ea : α → List αΓ} → {eb : β → List βΓ} → {f : α → β} → Turing.TM2ComputableInPolyTime ea eb f → Polynomial ℕ

a polynomial time function

abbrev Turing.TM2ComputableInPolyTime.outputsFun E1 #

{α β αΓ βΓ : Type} →
  {ea : α → List αΓ} →
    {eb : β → List βΓ} →
      {f : α → β} →
        (self : Turing.TM2ComputableInPolyTime ea eb f) →
          (a : α) →
            Turing.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 f in at most time(input.length) steps

def Turing.TM2ComputableInTime.toTM2Computable E1 #

{α β αΓ βΓ : Type} →
  {ea : α → List αΓ} →
    {eb : β → List βΓ} → {f : α → β} → Turing.TM2ComputableInTime ea eb f → Turing.TM2Computable ea eb f

A forgetful map, forgetting the time bound on the number of steps.

def Turing.TM2ComputableInPolyTime.toTM2ComputableInTime E1 #

{α β αΓ βΓ : Type} →
  {ea : α → List αΓ} →
    {eb : β → List βΓ} → {f : α → β} → Turing.TM2ComputableInPolyTime ea eb f → Turing.TM2ComputableInTime ea eb f

A forgetful map, forgetting that the time function is polynomial.

def Turing.idComputer E1 #

(αΓ : Type) → [Fintype αΓ] → Turing.FinTM2

A Turing machine computing the identity on α.

instance Turing.inhabitedFinTM2 E0 #

Inhabited Turing.FinTM2

def Turing.idComputableInPolyTime E3 #

{α αΓ : Type} → [Fintype αΓ] → (ea : α → List αΓ) → Turing.TM2ComputableInPolyTime ea ea id

A proof that the identity map on α is computable in polytime.

instance Turing.inhabitedTM2ComputableInPolyTime E0 #

Inhabited (Turing.TM2ComputableInPolyTime Computability.encodeBool Computability.encodeBool id)

instance Turing.inhabitedTM2OutputsInTime E0 #

Inhabited
  (Turing.TM2OutputsInTime (Turing.idComputer Bool) (List.map (Equiv.cast ⋯).invFun [false])
    (some (List.map (Equiv.cast ⋯).invFun [false])) (Polynomial.eval 1 1))

instance Turing.inhabitedTM2Outputs E0 #

Inhabited
  (Turing.TM2Outputs (Turing.idComputer Bool) (List.map (Equiv.cast ⋯).invFun [false])
    (some (List.map (Equiv.cast ⋯).invFun [false])))

instance Turing.inhabitedEvalsToInTime E0 #

Inhabited (StateTransition.EvalsToInTime (fun x ↦ some PUnit.unit) PUnit.unit (some PUnit.unit) 0)

instance Turing.inhabitedTM2EvalsTo E0 #

Inhabited (StateTransition.EvalsTo (fun x ↦ some PUnit.unit) PUnit.unit (some PUnit.unit))

def Turing.idComputableInTime E1 #

{α αΓ : Type} → [Fintype αΓ] → (ea : α → List αΓ) → Turing.TM2ComputableInTime ea ea id

A proof that the identity map on α is computable in time.

instance Turing.inhabitedTM2ComputableInTime E0 #

Inhabited (Turing.TM2ComputableInTime Computability.encodeBool Computability.encodeBool id)

def Turing.idComputable E3 #

{α αΓ : Type} → [Fintype αΓ] → (ea : α → List αΓ) → Turing.TM2Computable ea ea id

A proof that the identity map on α is computable.

instance Turing.inhabitedTM2Computable E0 #

Inhabited (Turing.TM2Computable Computability.encodeBool Computability.encodeBool id)

instance Turing.inhabitedTM2ComputableAux E0 #

Inhabited (Turing.TM2ComputableAux Bool Bool)