Summary: I want to implement an interpreter for $\mu$-recursive functions which, for any $\mu$-recursive function $f$ and input $\mathbf{x}$, returns $f \left( \mathbf{x} \right)$ if it is defined.
Let's define MuRec : nat -> Set
represent the syntax of $\mu$-recursive functions by:
Inductive MuRec : nat -> Set :=
| MR_succ : MuRec 1
| MR_zero : MuRec 0
| MR_proj {n : nat} (i : Fin.t n) : MuRec n
| MR_compose {n : nat} {m : nat} (g : MuRecs n m) (h : MuRec m) : MuRec n
| MR_primRec {n : nat} (g : MuRec n) (h : MuRec (S (S n))) : MuRec (S n)
| MR_mu {n : nat} (g : MuRec (S n)) : MuRec n
with MuRecs : nat -> nat -> Set :=
| MRs_nil {n : nat} : MuRecs n 0
| MRs_cons {n : nat} {m : nat} (f : MuRec n) (fs : MuRecs n m) : MuRecs n (S m).
and define the semantics of $\mu$-recursive functions by:
Inductive MuRecSpec : forall n : nat, MuRec n -> Vector.t Value n -> Value -> Prop :=
| MR_succ_spec x
: MuRecSpec 1 (MR_succ) [x] (S x)
| MR_zero_spec
: MuRecSpec 0 (MR_zero) [] 0
| MR_proj_spec n xs i
: MuRecSpec n (MR_proj i) xs (xs [@ i ])
| MR_compose_spec n m g h xs ys z
(g_spec : MuRecsSpec n m g xs ys)
(h_spec : MuRecSpec m h ys z)
: MuRecSpec n (MR_compose g h) xs z
| MR_primRec_spec_O n g h xs z
(g_spec : MuRecSpec n g xs z)
: MuRecSpec (S n) (MR_primRec g h) (0 :: xs) z
| MR_primRec_spec_S n g h xs z a acc
(ACC : MuRecSpec (S n) (MR_primRec g h) (a :: xs) acc)
(h_spec : MuRecSpec (S (S n)) h (a :: acc :: xs) z)
: MuRecSpec (S n) (MR_primRec g h) (S a :: xs) z
| MR_mu_spec n g xs z
(g_spec : MuRecSpec (S n) g (z :: xs) 0)
(MIN : forall y, y < z -> exists p, p > 0 /\ MuRecSpec (S n) g (y :: xs) p)
: MuRecSpec n (MR_mu g) xs z
with MuRecsSpec : forall n : nat, forall m : nat, MuRecs n m -> Vector.t Value n -> Vector.t Value m -> Prop :=
| MRs_nil_spec n xs
: MuRecsSpec n 0 MRs_nil xs []
| MRs_cons_spec n m xs y ys f fs
(f_spec : MuRecSpec n f xs y)
(fs_spec : MuRecsSpec n m fs xs ys)
: MuRecsSpec n (S m) (MRs_cons f fs) xs (y :: ys).
We say $f \left( \mathbf{x} \right)$ is defined as $z$ if $\mathtt{MuRecSpec} \, n \, f \, \mathbf{x} \, z$ holds for $n$-ary $\mu$-recursive function $f$ and input $\mathbf{x}$ and denote by $$ f \left( \mathbf{x} \right) = z . $$
Now let $f : \mathtt{Murec} \, n$ with $n \in \mathbb{N}$.
Question: Given $\mathbf{x} \in \mathbb{N}^n$, if there exists $z \in \mathbb{N}$ s.t. $f \left( \mathbf{x} \right) = z$ holds, then can we find such $z$?
I know we could assume the following axiom:
ConstructiveIndefiniteDescription := forall A : Type, forall P : A -> Prop, (exists x, P x) -> { x : A | P x }.
But I want to prove
Theorem MuRecInterpreter (n : nat) (f : MuRec n) (xs : Vector.t nat n)
(CONVERGE : exists z, MuRecSpec n f xs z)
: { z : nat | MuRecSpec n f xs z }.
without axioms. Is it possible?
Prop
come into account. $\endgroup$