Totality problem for programs
DefinitionTotal codes#✓fully proved
A code \(c\) of a partial recursive function is total when it halts on every input: writing \(\varphi_c\) for the partial function on \(\mathbb{N}\) that \(c\) computes, \(\varphi_c(n)\) is defined for every \(n \in \mathbb{N}\).
def TotalCode (c : Code) : Prop := ∀ n, (c.eval n).Dom
TheoremHalting on zero reduces to totality#✓fully proved
Writing \(\varphi_c\) for the partial function on \(\mathbb{N}\) computed by a code \(c\) of a partial recursive function, the set of codes \(c\) with \(\varphi_c(0)\) defined is many-one reducible to the set of total codes, the codes that halt on every input: there is a computable function \(f\) from codes to codes such that, for every code \(c\), \(\varphi_c(0)\) is defined if and only if \(f(c)\) is total.
theorem manyOneReducible_halting_total :
ManyOneReducible (fun c : Code ↦ (c.eval 0).Dom) TotalCode
def TotalCode (c : Code) : Prop := ∀ n, (c.eval n).Dom
CSLibExt/Computability/Decidability/Totality.lean:48
Uses 2 · Used by 1
TheoremTotality is not co-recognizable#✓fully proved
The set of total codes, the codes of partial recursive functions that halt on every input, is not co-recognizable by multi-stack machines: no multi-stack machine halts on the binary encoding of a code \(c\) exactly when \(c\) is not total.
theorem not_tm2CoRecognizable_total : ¬TM2CoRecognizable TotalCode
def TM2CoRecognizable (p : α → Prop) : Prop := TM2Recognizable fun a ↦ ¬p a
CSLibExt/Computability/Decidability/Basic.lean:70
def TotalCode (c : Code) : Prop := ∀ n, (c.eval n).Dom
CSLibExt/Computability/Decidability/Totality.lean:48
DefinitionDiverging once a code halts on zero#✓fully proved
For a code \(c\) of a partial recursive function, this is the partial function \(\mathbb{N} \to \mathbb{N}\) that on input \(k\) is undefined if \(c\) halts on input \(0\) within \(k\) steps of bounded evaluation, and equals \(0\) otherwise.
def untilHaltsFun (c : Code) (k : ℕ) : Part ℕ :=
bif (Code.evaln k c 0).isSome then Part.none else Part.some 0
TheoremNon-halting on zero reduces to totality#✓fully proved
Writing \(\varphi_c\) for the partial function on \(\mathbb{N}\) computed by a code \(c\) of a partial recursive function, the set of codes \(c\) with \(\varphi_c(0)\) undefined is many-one reducible to the set of total codes, the codes that halt on every input: there is a computable function \(f\) from codes to codes such that, for every code \(c\), \(\varphi_c(0)\) is undefined if and only if \(f(c)\) is total.
theorem manyOneReducible_not_halting_total :
ManyOneReducible (fun c : Code ↦ ¬(c.eval 0).Dom) TotalCode
def TotalCode (c : Code) : Prop := ∀ n, (c.eval n).Dom
CSLibExt/Computability/Decidability/Totality.lean:48
Uses 3 · Used by 1
TheoremTotality is not recognizable#✓fully proved
The set of total codes, the codes of partial recursive functions that halt on every input, is not recognizable by multi-stack machines: no multi-stack machine halts on the binary encoding of a code \(c\) exactly when \(c\) is total.
theorem not_tm2Recognizable_total : ¬TM2Recognizable TotalCode
def TM2Recognizable (p : α → Prop) : Prop :=
∃ (tm : FinTM2) (e : tm.Γ tm.k₀ ≃ Bool),
∀ a, p a ↔ TM2HaltsOn tm ((encodeNat (encode a)).map e.symm)
CSLibExt/Computability/Decidability/Basic.lean:65
def TotalCode (c : Code) : Prop := ∀ n, (c.eval n).Dom
CSLibExt/Computability/Decidability/Totality.lean:48
Uses 5 · Used by 1
TheoremTotality is undecidable#✓fully proved
The set of total codes, the codes of partial recursive functions that halt on every input, is not decidable by multi-stack machines: no multi-stack machine computes a total function \(f : \mathbb{N} \to \mathbb{N}\) that takes the value \(1\) at the number encoding a code \(c\) exactly when \(c\) is total.
theorem not_tm2Decidable_total : ¬TM2Decidable TotalCode
def TM2Decidable (p : α → Prop) : Prop :=
∃ f : ℕ → ℕ, Nonempty (TM2Computable encodeNat encodeNat f) ∧ ∀ a, f (encode a) = 1 ↔ p a
CSLibExt/Computability/Decidability/Basic.lean:60
def TotalCode (c : Code) : Prop := ∀ n, (c.eval n).Dom
CSLibExt/Computability/Decidability/Totality.lean:48
Uses 4
Loading dependency explorer…
The dependency explorer needs JavaScript and its graph data.