Documentation

CslibFrontier.Foundations.Computability.ComputablePred

Closure properties of computable predicates #

Mathlib's ComputablePred p states that p has a computable Boolean indicator. Mathlib proves closure under negation (ComputablePred.not); this file adds closure under conjunction, disjunction, implication, composition with computable functions, comparisons of computable natural-number functions, and bounded quantification. The bounded quantifiers are the computable analogues of Mathlib's PrimrecPred.forall_lt and PrimrecPred.exists_lt: a bound computed from the parameter, over a predicate decidable in the parameter and the bound variable together. Unbounded existential quantification of a computable predicate gives an r.e. predicate (ComputablePred.rePred_exists), and r.e. predicates are closed under substitution of computable functions (REPred.comp). A predicate is r.e. exactly when it is the domain of a code of Nat.Partrec.Code, evaluated at the encoded argument (rePred_iff_exists_code).

The generic form of an incompleteness argument: if p is not r.e., then every r.e. predicate that implies p misses a point of p (REPred.exists_not_of_not_rePred), and every decidable relation P a b ("b is a proof of a") that is sound for p leaves a point of p without a proof (ComputablePred.exists_forall_not_of_not_rePred). The variants REPred.exists_not_of_not_exists_rePred_iff and ComputablePred.exists_forall_not_of_not_exists_rePred_iff only assume that no r.e. predicate agrees with p on a domain D, and find the point in D.

Main results #

theorem ComputablePred.and {α : Type u_1} [Primcodable α] {p q : α → Prop} (hp : ComputablePred p) (hq : ComputablePred q) :
ComputablePred fun (a : α) => p a ∧ q a

Computable predicates are closed under conjunction.

theorem ComputablePred.or {α : Type u_1} [Primcodable α] {p q : α → Prop} (hp : ComputablePred p) (hq : ComputablePred q) :
ComputablePred fun (a : α) => p a ∨ q a

Computable predicates are closed under disjunction.

theorem ComputablePred.imp {α : Type u_1} [Primcodable α] {p q : α → Prop} (hp : ComputablePred p) (hq : ComputablePred q) :
ComputablePred fun (a : α) => p a → q a

Computable predicates are closed under implication.

theorem ComputablePred.comp {α : Type u_1} {β : Type u_2} [Primcodable α] [Primcodable β] {p : β → Prop} {f : α → β} (hp : ComputablePred p) (hf : Computable f) :
ComputablePred fun (a : α) => p (f a)

Substituting a computable function into a computable predicate gives a computable predicate.

theorem ComputablePred.nat_le {α : Type u_1} [Primcodable α] {f g : α → ℕ} (hf : Computable f) (hg : Computable g) :
ComputablePred fun (a : α) => f a ≤ g a

Comparing two computable natural-number functions with ≤ is computable.

theorem ComputablePred.nat_lt {α : Type u_1} [Primcodable α] {f g : α → ℕ} (hf : Computable f) (hg : Computable g) :
ComputablePred fun (a : α) => f a < g a

Comparing two computable natural-number functions with < is computable.

theorem ComputablePred.forall_lt {α : Type u_1} [Primcodable α] {p : α → ℕ → Prop} (hp : ComputablePred (Function.uncurry p)) {f : α → ℕ} (hf : Computable f) :
ComputablePred fun (a : α) => ∀ i < f a, p a i

Bounded universal quantification preserves computability: if p a i is computable in (a, i) and the bound f a is computable, then ∀ i < f a, p a i is computable.

theorem ComputablePred.exists_lt {α : Type u_1} [Primcodable α] {p : α → ℕ → Prop} (hp : ComputablePred (Function.uncurry p)) {f : α → ℕ} (hf : Computable f) :
ComputablePred fun (a : α) => ∃ i < f a, p a i

Bounded existential quantification preserves computability: if p a i is computable in (a, i) and the bound f a is computable, then ∃ i < f a, p a i is computable.

theorem ComputablePred.exists_mem_list {α : Type u_1} {β : Type u_2} [Primcodable α] [Primcodable β] {p : α → β → Prop} (hp : ComputablePred (Function.uncurry p)) {f : α → List β} (hf : Computable f) :
ComputablePred fun (a : α) => ∃ b ∈ f a, p a b

Existential quantification over the members of a list preserves computability: if p a b is computable in (a, b) and the list f a is computable, then ∃ b ∈ f a, p a b is computable. This is the computable analogue of Mathlib's PrimrecRel.exists_mem_list.

theorem ComputablePred.rePred_exists {α : Type u_1} {β : Type u_2} [Primcodable α] [Primcodable β] {p : α → β → Prop} (hp : ComputablePred (Function.uncurry p)) :
REPred fun (a : α) => ∃ (b : β), p a b

Unbounded existential quantification of a computable predicate is r.e.: search for a witness by Nat.rfind over the codes of β.

theorem REPred.comp {α : Type u_1} {β : Type u_2} [Primcodable α] [Primcodable β] {p : β → Prop} (hp : REPred p) {f : α → β} (hf : Computable f) :
REPred fun (a : α) => p (f a)

Substituting a computable function into an r.e. predicate gives an r.e. predicate.

theorem REPred.exists_not_of_not_exists_rePred_iff {α : Type u_1} [Primcodable α] {D p S : α → Prop} (hp : ¬∃ (T : α → Prop), REPred T ∧ ∀ (a : α), D a → (T a ↔ p a)) (hS : REPred S) (hsound : ∀ (a : α), S a → p a) :
∃ (a : α), D a ∧ p a ∧ ¬S a

An r.e. predicate that implies a non-r.e. one misses a point, relative to a domain. If no r.e. predicate agrees with p on D, then every r.e. S that implies p misses some point of D where p holds.

theorem REPred.exists_not_of_not_rePred {α : Type u_1} [Primcodable α] {p S : α → Prop} (hp : ¬REPred p) (hS : REPred S) (hsound : ∀ (a : α), S a → p a) :
∃ (a : α), p a ∧ ¬S a

An r.e. predicate that implies a non-r.e. one misses a point. If p is not r.e., every r.e. S that implies p misses some point where p holds.

theorem ComputablePred.exists_forall_not_of_not_exists_rePred_iff {α : Type u_1} {β : Type u_2} [Primcodable α] [Primcodable β] {D p : α → Prop} {P : α → β → Prop} (hP : ComputablePred (Function.uncurry P)) (hp : ¬∃ (T : α → Prop), REPred T ∧ ∀ (a : α), D a → (T a ↔ p a)) (hsound : ∀ (a : α) (b : β), P a b → p a) :
∃ (a : α), D a ∧ p a ∧ ∀ (b : β), ¬P a b

A sound decidable proof relation for a non-r.e. predicate is incomplete, relative to a domain. If no r.e. predicate agrees with p on D, and P a b ("b is a proof of a") is decidable and only points of p have proofs, then some point of D where p holds has no proof.

theorem ComputablePred.exists_forall_not_of_not_rePred {α : Type u_1} {β : Type u_2} [Primcodable α] [Primcodable β] {p : α → Prop} {P : α → β → Prop} (hP : ComputablePred (Function.uncurry P)) (hp : ¬REPred p) (hsound : ∀ (a : α) (b : β), P a b → p a) :
∃ (a : α), p a ∧ ∀ (b : β), ¬P a b

A sound decidable proof relation for a non-r.e. predicate is incomplete. If p is not r.e., and P a b ("b is a proof of a") is decidable and only points of p have proofs, then some point where p holds has no proof.

theorem rePred_iff_exists_code {α : Type u_1} [Primcodable α] {p : α → Prop} :
REPred p ↔ ∃ (c : Nat.Partrec.Code), ∀ (a : α), p a ↔ (c.eval (Encodable.encode a)).Dom

A predicate is r.e. exactly when it is the domain of a code: p a holds iff the code c halts on encode a.