Definition ReplaceFormulaTerm : nat -> nat -> nat :=
evalStrongRec 1
(fun f recs s : nat =>
switchPR (cPairPi1 f)
(switchPR (pred (cPairPi1 f))
(switchPR (pred (pred (cPairPi1 f)))
(switchPR (pred (pred (pred (cPairPi1 f))))
(cPair (cPairPi1 f) (ReplaceTermsTerm (cPairPi2 f) s))
(cPair 3
(cPair s (codeNth (f - S (cPairPi2 (cPairPi2 f))) recs))))
(cPair 2 (codeNth (f - S (cPairPi2 f)) recs)))
(cPair 1
(cPair (codeNth (f - S (cPairPi1 (cPairPi2 f))) recs)
(codeNth (f - S (cPairPi2 (cPairPi2 f))) recs))))
(cPair 0
(cPair (ReplaceTermTerm (cPairPi1 (cPairPi2 f)) s)
(ReplaceTermTerm (cPairPi2 (cPairPi2 f)) s)))).

(* Specifications: *)
Lemma ReplaceFormulaTermIsPR : isPR 2 ReplaceFormulaTerm.
Lemma ReplaceFormulaTermMonotone :
forall a s1 s2 : nat,
s1 <= s2 -> ReplaceFormulaTerm a s1 <= ReplaceFormulaTerm a s2.