Zulip Chat Archive

Stream: new members

Topic: Range of a p.c. function is C.E.


Janitha Aswedige (Oct 20 2025 at 17:50):

I'm trying to prove that the range of a partial computable function is computably enumerable. I formalized the statement and I think it's correct. I just don't know if this has already been done. Any help is appreciated.

theorem rangePartrec_REPred {p :   Prop} (hp :  (f :  →. ), Nat.Partrec f   x, p x   y, x  f y ) :
    REPred p := by
      sorry

Aaron Liu (Oct 20 2025 at 18:44):

The statement looks correct but it's stated kind of weirdly

Matt Diamond (Oct 20 2025 at 23:27):

it might be simpler to state it like this:

theorem rangePartrec_REPred (f :  →. ) (hf : Nat.Partrec f) : REPred (fun x =>  y, x  f y) := sorry

Matt Diamond (Oct 21 2025 at 03:34):

I spent way too long on this but here's a proof:

import Mathlib.Computability.Halting

open Nat.Partrec Primrec

lemma evaln_eq_some_prim (c : Code) : PrimrecRel fun (x y : ) => c.evaln y.unpair.1 y.unpair.2 = some x :=
Primrec.eq.comp
  (Code.primrec_evaln.comp (.pair (.pair (fst.comp (unpair.comp .snd)) (.const c)) (snd.comp (unpair.comp .snd))))
  (Primrec.option_some.comp .fst)

theorem rangePartrec_REPred (f :  →. ) (hf : Nat.Partrec f) : REPred (fun y =>  x, y  f x) :=
by
  obtain c, hc := Code.exists_code.mp hf
  have : REPred fun (y : ) => (Nat.rfindOpt fun x => if c.evaln x.unpair.1 x.unpair.2 = some y then some () else none).Dom := by
    apply Partrec.dom_re
    apply Partrec.rfindOpt
    exact (Primrec.ite (evaln_eq_some_prim c) (.const _) (.const _)).to_comp
  apply this.of_eq
  intro y
  rw [Nat.rfindOpt_dom,  hc]
  constructor
  · intro x, (), hx
    have h : y  c.evaln x.unpair.1 x.unpair.2 := by simpa using hx
    use x.unpair.2
    exact Code.evaln_sound h
  · intro x, hx
    rw [Code.evaln_complete] at hx
    obtain k, hk := hx
    use Nat.pair k x, ()
    simpa using hk

Janitha Aswedige (Oct 21 2025 at 04:11):

@Matt Diamond Thanks this is neat. What I originally wanted to prove is that the image of a C.E. predicate under a partial computable function is C.E. Thought this theorem would help. Now I'm trying to figure that out.


Last updated: Dec 20 2025 at 21:32 UTC