Definition codeSubFormula (f v s : nat) : nat :=
let C := cPair 0 (pow3 f + (v + (s + f))) in
cPairPi1
(boundedSearch
(fun p x : nat =>
ltBool 0 (checkSubFormulaTrace (cPair (cPairPi1 p) x)))
(cPair (cTriple v s f)
(S
(boundComputation f (cTriple C C (ReplaceFormulaTerm f C))
(ReplaceFormulaTerm f C))))).

(* Specifications: *)
Lemma codeSubFormulaCorrect :
forall (f : Formula) (v : nat) (s : Term),
codeSubFormula (codeFormula f) v (codeTerm s) =
codeFormula (substituteFormula L f v s).
Lemma codeSubFormulaIsPR : isPR 3 codeSubFormula.
End Code_Substitute_Formula.