mathlib documentation

computability.halting

Computability theory and the halting problem #

A universal partial recursive function, Rice's theorem, and the halting problem.

References #

theorem nat.partrec.merge' {f g : ℕ →. ℕ} (hf : nat.partrec f) (hg : nat.partrec g) :
∃ (h : ℕ →. ℕ), nat.partrec h ∧ ∀ (a : ℕ), (∀ (x : ℕ), x ∈ h a → x ∈ f a ∨ x ∈ g a) ∧ ((h a).dom ↔ (f a).dom ∨ (g a).dom)
theorem partrec.merge' {α : Type u_1} {σ : Type u_4} [primcodable α] [primcodable σ] {f g : α →. σ} (hf : partrec f) (hg : partrec g) :
∃ (k : α →. σ), partrec k ∧ ∀ (a : α), (∀ (x : σ), x ∈ k a → x ∈ f a ∨ x ∈ g a) ∧ ((k a).dom ↔ (f a).dom ∨ (g a).dom)
theorem partrec.merge {α : Type u_1} {σ : Type u_4} [primcodable α] [primcodable σ] {f g : α →. σ} (hf : partrec f) (hg : partrec g) (H : ∀ (a : α) (x : σ), x ∈ f a → ∀ (y : σ), y ∈ g a → x = y) :
∃ (k : α →. σ), partrec k ∧ ∀ (a : α) (x : σ), x ∈ k a ↔ x ∈ f a ∨ x ∈ g a
theorem partrec.cond {α : Type u_1} {σ : Type u_4} [primcodable α] [primcodable σ] {c : α → bool} {f g : α →. σ} (hc : computable c) (hf : partrec f) (hg : partrec g) :
partrec (λ (a : α), cond (c a) (f a) (g a))
theorem partrec.sum_cases {α : Type u_1} {β : Type u_2} {γ : Type u_3} {σ : Type u_4} [primcodable α] [primcodable β] [primcodable γ] [primcodable σ] {f : α → β ⊕ γ} {g : α → β →. σ} {h : α → γ →. σ} (hf : computable f) (hg : partrec₂ g) (hh : partrec₂ h) :
partrec (λ (a : α), (f a).cases_on (g a) (h a))
def computable_pred {α : Type u_1} [primcodable α] (p : α → Prop) :
Prop

A computable predicate is one whose indicator function is computable.

Equations
def re_pred {α : Type u_1} [primcodable α] (p : α → Prop) :
Prop

A recursively enumerable predicate is one which is the domain of a computable partial function.

Equations
theorem re_pred.of_eq {α : Type u_1} [primcodable α] {p q : α → Prop} (hp : re_pred p) (H : ∀ (a : α), p a ↔ q a) :
theorem partrec.dom_re {α : Type u_1} {β : Type u_2} [primcodable α] [primcodable β] {f : α →. β} (h : partrec f) :
re_pred (λ (a : α), (f a).dom)
theorem computable_pred.of_eq {α : Type u_1} [primcodable α] {p q : α → Prop} (hp : computable_pred p) (H : ∀ (a : α), p a ↔ q a) :
theorem computable_pred.computable_iff {α : Type u_1} [primcodable α] {p : α → Prop} :
computable_pred p ↔ ∃ (f : α → bool), computable f ∧ p = λ (a : α), ↥(f a)
@[protected]
theorem computable_pred.not {α : Type u_1} [primcodable α] {p : α → Prop} (hp : computable_pred p) :
computable_pred (λ (a : α), ¬p a)
theorem computable_pred.to_re {α : Type u_1} [primcodable α] {p : α → Prop} (hp : computable_pred p) :
theorem computable_pred.rice (C : set (ℕ →. ℕ)) (h : computable_pred (λ (c : nat.partrec.code), c.eval ∈ C)) {f g : ℕ →. ℕ} (hf : nat.partrec f) (hg : nat.partrec g) (fC : f ∈ C) :
g ∈ C
theorem computable_pred.rice₂ (C : set nat.partrec.code) (H : ∀ (cf cg : nat.partrec.code), cf.eval = cg.eval → (cf ∈ C ↔ cg ∈ C)) :
@[nolint]
theorem computable_pred.computable_iff_re_compl_re {α : Type u_1} [primcodable α] {p : α → Prop} [decidable_pred p] :
computable_pred p ↔ re_pred p ∧ re_pred (λ (a : α), ¬p a)
theorem computable_pred.computable_iff_re_compl_re' {α : Type u_1} [primcodable α] {p : α → Prop} :
computable_pred p ↔ re_pred p ∧ re_pred (λ (a : α), ¬p a)
inductive nat.partrec' {n : ℕ} :
(vector ℕ n →. ℕ) → Prop

A simplified basis for partrec.

theorem nat.partrec'.to_part {n : ℕ} {f : vector ℕ n →. ℕ} (pf : nat.partrec' f) :
theorem nat.partrec'.of_eq {n : ℕ} {f g : vector ℕ n →. ℕ} (hf : nat.partrec' f) (H : ∀ (i : vector ℕ n), f i = g i) :
theorem nat.partrec'.of_prim {n : ℕ} {f : vector ℕ n → ℕ} (hf : primrec f) :
theorem nat.partrec'.tail {n : ℕ} {f : vector ℕ n →. ℕ} (hf : nat.partrec' f) :
nat.partrec' (λ (v : vector ℕ n.succ), f v.tail)
@[protected]
theorem nat.partrec'.bind {n : ℕ} {f : vector ℕ n →. ℕ} {g : vector ℕ (n + 1) →. ℕ} (hf : nat.partrec' f) (hg : nat.partrec' g) :
nat.partrec' (λ (v : vector ℕ n), (f v).bind (λ (a : ℕ), g (a ::ᵥ v)))
@[protected]
theorem nat.partrec'.map {n : ℕ} {f : vector ℕ n →. ℕ} {g : vector ℕ (n + 1) → ℕ} (hf : nat.partrec' f) (hg : nat.partrec' ↑g) :
nat.partrec' (λ (v : vector ℕ n), part.map (λ (a : ℕ), g (a ::ᵥ v)) (f v))
def nat.partrec'.vec {n m : ℕ} (f : vector ℕ n → vector ℕ m) :
Prop

Analogous to nat.partrec' for ℕ-valued functions, a predicate for partial recursive vector-valued functions.

Equations
theorem nat.partrec'.vec.prim {n m : ℕ} {f : vector ℕ n → vector ℕ m} (hf : nat.primrec'.vec f) :
@[protected]
theorem nat.partrec'.nil {n : ℕ} :
@[protected]
theorem nat.partrec'.cons {n m : ℕ} {f : vector ℕ n → ℕ} {g : vector ℕ n → vector ℕ m} (hf : nat.partrec' ↑f) (hg : nat.partrec'.vec g) :
nat.partrec'.vec (λ (v : vector ℕ n), f v ::ᵥ g v)
theorem nat.partrec'.comp' {n m : ℕ} {f : vector ℕ m →. ℕ} {g : vector ℕ n → vector ℕ m} (hf : nat.partrec' f) (hg : nat.partrec'.vec g) :
nat.partrec' (λ (v : vector ℕ n), f (g v))
theorem nat.partrec'.comp₁ {n : ℕ} (f : ℕ →. ℕ) {g : vector ℕ n → ℕ} (hf : nat.partrec' (λ (v : vector ℕ 1), f v.head)) (hg : nat.partrec' ↑g) :
nat.partrec' (λ (v : vector ℕ n), f (g v))
theorem nat.partrec'.rfind_opt {n : ℕ} {f : vector ℕ (n + 1) → ℕ} (hf : nat.partrec' ↑f) :
nat.partrec' (λ (v : vector ℕ n), nat.rfind_opt (λ (a : ℕ), denumerable.of_nat (option ℕ) (f (a ::ᵥ v))))
theorem nat.partrec'.of_part {n : ℕ} {f : vector ℕ n →. ℕ} :