Post’s theorem: RE ∩ co-RE = recursive
Statement
A language L is recursive (decidable) if and only if both L and its
complement Lᶜ are recursively enumerable (semi-decidable). Equivalently,
RE ∩ co-RE = Recursive. Langlib formalizes the substantive direction: if L and
Lᶜ are both RE, then L is recursive.
In Lean
is_Recursive_of_isRE_of_isRE_compl— recursive form:is_RE L → is_RE Lᶜ → is_Recursive L.computablePred_of_isRE_of_isRE_compl— computability form: yields an explicitComputablePreddecider.REPred_mem_of_is_RE— bridges the language-level RE predicate to a computability-theoreticRePred.
Proof idea
The argument reduces to Mathlib’s computability-theoretic version of Post’s theorem,
ComputablePred.computable_iff_re_compl_re': a predicate is computable iff both it and
its negation are RePred (recursively enumerable).
-
Membership is an
RePredfor any RE language (REPred_mem_of_is_RE). Given a grammarggeneratingL,grammar_equivalent_finiteNTreplaces it by an equivalent grammarg'with finitely many nonterminals (madePrimcodable). Membership ofwis then the semi-decidable search∃ seq, grammarTest g' seq w = trueover candidate derivation sequences. This is exposed as a domain ofNat.rfind— decoding each natural to a sequence viaEncodable.decodeand testing it with the computablegrammarTest g'(grammarTest_computable₂) — so it isPartrec; its domain is theRePred. Soundness/completeness of the search (grammarTest_sound/grammarTest_complete) identify this domain withw ∈ L. -
From RE ∩ co-RE to computable membership (
computablePred_of_isRE_of_isRE_compl). Apply step 1 toLand toLᶜ(rewritingRePredof the complement throughSet.mem_compl_iff), then feed bothRePredfacts toComputablePred.computable_iff_re_compl_re'to get aComputablePred. -
From computable membership to recursive (
is_Recursive_of_isRE_of_isRE_compl).ComputablePred.computable_iffextracts a total computable deciderf, whichis_Recursive_of_computable_decidecompiles into an always-haltingTuring.TM0decider, i.e.is_Recursive L.
Keywords / also known as
Post’s theorem, RE intersect co-RE equals recursive, decidable iff semidecidable and co-semidecidable, recursive equals RE and co-RE, complementation theorem for recursively enumerable sets, Emil Post theorem computability.
Formalized in Lean 4 with Mathlib, in Langlib.