Emptiness and equivalence problems for programs
DefinitionCodes with empty domain#✓fully proved
The set \(E\) consists of the codes \(c\) of partial recursive functions on \(\mathbb{N}\) that are defined on no input: for every \(n \in \mathbb{N}\), the function computed by \(c\) is undefined at \(n\).
def EmptyCode (c : Code) : Prop := ∀ n, ¬(c.eval n).Dom
TheoremEmptiness is undecidable#✓fully proved
The set \(E\) of codes of partial recursive functions on \(\mathbb{N}\) that are defined on no input is not decidable by multi-stack machines.
By Rice's theorem: the identity function is defined, the empty function is not.
theorem not_tm2Decidable_empty : ¬TM2Decidable EmptyCode
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 EmptyCode (c : Code) : Prop := ∀ n, ¬(c.eval n).Dom
CSLibExt/Computability/Decidability/RiceApplications.lean:46
Uses 3 · Used by 1
TheoremNonemptiness is recognizable#✓fully proved
The set of codes of partial recursive functions \(\mathbb{N} \to \mathbb{N}\) that are defined on at least one input is recognizable by multi-stack machines: some multi-stack machine halts on the binary encoding of a code \(c\) exactly when the function coded by \(c\) is defined on some input.
The machine searches for an input \(n\) and a step bound \(k\) such that the evaluation of \(c\) on \(n\) halts within \(k\) steps.
theorem tm2Recognizable_not_empty : TM2Recognizable fun c ↦ ¬EmptyCode c
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 EmptyCode (c : Code) : Prop := ∀ n, ¬(c.eval n).Dom
CSLibExt/Computability/Decidability/RiceApplications.lean:46
Uses 3 · Used by 1
TheoremEmptiness is co-recognizable#✓fully proved
The set of codes of partial recursive functions \(\mathbb{N} \to \mathbb{N}\) that are defined on no input is co-recognizable by multi-stack machines: some multi-stack machine halts on the binary encoding of a code \(c\) exactly when the function coded by \(c\) is defined on at least one input.
theorem tm2CoRecognizable_empty : TM2CoRecognizable EmptyCode
def TM2CoRecognizable (p : α → Prop) : Prop := TM2Recognizable fun a ↦ ¬p a
CSLibExt/Computability/Decidability/Basic.lean:70
def EmptyCode (c : Code) : Prop := ∀ n, ¬(c.eval n).Dom
CSLibExt/Computability/Decidability/RiceApplications.lean:46
Uses 3 · Used by 1
TheoremEmptiness is not recognizable#✓fully proved
The set \(E\) of codes of partial recursive functions on \(\mathbb{N}\) that are defined on no input is not recognizable by multi-stack machines: no multi-stack machine, started on the binary encoding of a code, halts exactly when the code is in \(E\).
Since \(E\) is co-recognizable, it would otherwise be decidable, by Post's theorem.
theorem not_tm2Recognizable_empty : ¬TM2Recognizable EmptyCode
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 EmptyCode (c : Code) : Prop := ∀ n, ¬(c.eval n).Dom
CSLibExt/Computability/Decidability/RiceApplications.lean:46
Uses 7 · Used by 1
DefinitionEquivalent codes#✓fully proved
The set \(EQ\) consists of the pairs \((c_1, c_2)\) of codes of partial recursive functions on \(\mathbb{N}\) that recognize the same language, that is, whose computed functions have the same domain: for every \(n \in \mathbb{N}\), the function computed by \(c_1\) is defined at \(n\) if and only if the function computed by \(c_2\) is.
TheoremA code defined nowhere#✓fully proved
There is a code \(e\) of a partial recursive function on \(\mathbb{N}\) whose computed function is the empty partial function, undefined at every input.
Used by 1
TheoremEmptiness reduces to equivalence#✓fully proved
The set \(E\) of codes of partial recursive functions defined on no input is many-one reducible to the set \(EQ\) of pairs of codes with the same domain: there is a computable map \(f\) from codes to pairs of codes such that, for every code \(c\), \(c \in E\) if and only if \(f(c) \in EQ\).
One can take \(f(c) = (c, e)\) for a code \(e\) defined nowhere.
theorem manyOneReducible_empty_eq : ManyOneReducible EmptyCode EqCode
def EmptyCode (c : Code) : Prop := ∀ n, ¬(c.eval n).Dom
CSLibExt/Computability/Decidability/RiceApplications.lean:46
def EqCode (p : Code × Code) : Prop := p.1.eval.Dom = p.2.eval.Dom
CSLibExt/Computability/Decidability/RiceApplications.lean:92
Uses 3 · Used by 1
TheoremEquivalence is not recognizable#✓fully proved
The set \(EQ\) of pairs of codes of partial recursive functions on \(\mathbb{N}\) with the same domain is not recognizable by multi-stack machines: no multi-stack machine, started on the binary encoding of a pair of codes, halts exactly when the pair is in \(EQ\).
theorem not_tm2Recognizable_eq : ¬TM2Recognizable EqCode
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 EqCode (p : Code × Code) : Prop := p.1.eval.Dom = p.2.eval.Dom
CSLibExt/Computability/Decidability/RiceApplications.lean:92
DefinitionHalting-on-zero code#✓fully proved
For a code \(c\) of a partial recursive function on \(\mathbb{N}\), the code \(h(c)\) is the composition \(k_0 \circ c \circ k_0\), where \(k_0\) is the code of the constant function \(0\): whatever its input, \(h(c)\) runs \(c\) on \(0\) and, if this halts, outputs \(0\).
def haltsOnZeroCode (c : Code) : Code :=
Code.comp (Code.const 0) (Code.comp c (Code.const 0))
Used by 2
TheoremHalting on zero reduces to equivalence#✓fully proved
The set of codes \(c\) of partial recursive functions on \(\mathbb{N}\) that halt on input \(0\) (are defined at \(0\)) is many-one reducible to the set \(EQ\) of pairs of codes with the same domain: there is a computable map \(f\) from codes to pairs of codes such that, for every code \(c\), \(c\) halts on \(0\) if and only if \(f(c) \in EQ\).
One can take \(f(c) = (h(c), k_0)\), where \(h(c)\) runs \(c\) on \(0\) and then outputs \(0\) whatever its input, and \(k_0\) is the code of the constant function \(0\).
theorem manyOneReducible_halting_eq :
ManyOneReducible (fun c : Code ↦ (c.eval 0).Dom) EqCode
def EqCode (p : Code × Code) : Prop := p.1.eval.Dom = p.2.eval.Dom
CSLibExt/Computability/Decidability/RiceApplications.lean:92
Uses 2 · Used by 1
TheoremEquivalence is not co-recognizable#✓fully proved
The set \(EQ\) of pairs of codes of partial recursive functions on \(\mathbb{N}\) with the same domain is not co-recognizable by multi-stack machines: no multi-stack machine, started on the binary encoding of a pair of codes, halts exactly when the pair is not in \(EQ\).
The complement of halting on \(0\) would reduce to the complement of equivalence.
theorem not_tm2CoRecognizable_eq : ¬TM2CoRecognizable EqCode
def TM2CoRecognizable (p : α → Prop) : Prop := TM2Recognizable fun a ↦ ¬p a
CSLibExt/Computability/Decidability/Basic.lean:70
def EqCode (p : Code × Code) : Prop := p.1.eval.Dom = p.2.eval.Dom
CSLibExt/Computability/Decidability/RiceApplications.lean:92
Loading dependency explorer…
The dependency explorer needs JavaScript and its graph data.