Remark makeTrace1 :
forall (f : fol.Formula L) (v : nat) (s : fol.Term L),
cTriplePi1 (makeTrace f (v, s)) = cTriple v (codeTerm s) (codeFormula f).
Remark makeTrace2 :
forall (f : fol.Formula L) (v : nat) (s : fol.Term L),
cTriplePi2 (makeTrace f (v, s)) = codeFormula (substituteFormula L f v s).

(* Specifications: *)
Lemma makeTraceCorrect :
forall (f : fol.Formula L) (v : nat) (s : fol.Term L),
checkSubFormulaTrace (makeTrace f (v, s)) = 1.
Lemma checkTraceCorrect :
forall (f : fol.Formula L) (v : nat) (s : fol.Term L) (n m : nat),
checkSubFormulaTrace (cTriple (cTriple v (codeTerm s) (codeFormula f)) n m) <>
0 -> codeFormula (substituteFormula L f v s) = n.
Lemma switch5IsPR :
forall (f1 f2 f3 f4 f5 : nat -> nat -> nat) (g : nat -> nat),
isPR 2 f1 ->
isPR 2 f2 ->
isPR 2 f3 ->
isPR 2 f4 ->
isPR 2 f5 ->
isPR 1 g ->
isPR 2
(fun n recs : nat =>
switchPR (g n)
(switchPR (pred (g n))
(switchPR (pred (pred (g n)))
(switchPR (pred (pred (pred (g n)))) (f1 n recs) (f2 n recs))
(f3 n recs)) (f4 n recs)) (f5 n recs)).
Lemma checkTraceIsPR : isPR 1 checkSubFormulaTrace.
Definition ReplaceTermTermsTerm : nat -> nat -> nat :=
evalStrongRec 1
(fun t recs s : nat =>
cPair
(switchPR (cPairPi1 t)
(cPair (cPairPi1 t) (cPairPi2 (codeNth (t - S (cPairPi2 t)) recs)))
(cPair 0 s))
(switchPR t
(S
(cPair (cPairPi1 (codeNth (t - S (cPairPi1 (pred t))) recs))
(cPairPi2 (codeNth (t - S (cPairPi2 (pred t))) recs)))) 0)).