Section PrimRecs_case.
Let cast (x : nat) (n : nat) (m : nat) (EQ : n = m) : PrimRecs x n -> PrimRecs x m :=
match EQ with
| eq_refl => fun xs => xs
end.
End PrimRecs_case.
Fixpoint runPrimRec {n : arity} (f : PrimRec n) {struct f} : naryFun n :=
match f with
| PR_succ => S
| PR_zero => O
| PR_proj n i => eval_proj (n := n) i
| PR_compose n m g h => eval_compose (n := n) (m := m) (runPrimRecs g) (runPrimRec h)
| PR_primRec n g h => eval_primRec (n := n) (runPrimRec g) (runPrimRec h)
end
with runPrimRecs {n : arity} {m : arity} (fs : PrimRecs n m) {struct fs} : Vector.t (naryFun n) m :=
match fs with
| PRs_nil n' => VNil
| PRs_cons n' m' f fs' => VCons m' (runPrimRec f) (runPrimRecs fs')
end.

Lemma runPrimRec_unfold (n : arity) (f : PrimRec n) :
runPrimRec f =
match f with
| PR_succ => S
| PR_zero => O
| PR_proj n i => eval_proj i
| PR_compose n m g h => eval_compose (runPrimRecs g) (runPrimRec h)
| PR_primRec n g h => eval_primRec (runPrimRec g) (runPrimRec h)
end.