Remark boundSubFormulaHelp2 :
forall (a : fol.Formula L) (v0 : nat) (s : fol.Term L),
newVar (v0 :: freeVarTerm L s ++ freeVarFormula L a) <=
S
(fold_right max 0
(v0 :: fold_right max 0 (freeVarTerm L s) :: varFormula a)).
intros.
unfold newVar in |- *.
apply
le_trans
with (S (fold_right max 0 (v0 :: freeVarTerm L s ++ freeVarFormula L a))).
apply mapListLemma.
apply le_n_S.
simpl in |- *.
apply maxLemma.
apply le_n.
induction (maxApp (freeVarTerm L s) (freeVarFormula L a)).
rewrite a0.
apply le_max_l.
rewrite b.
eapply le_trans.
apply maxVarFreeVar.
apply le_max_r.
Qed.
Remark boundSubFormulaHelp1 :
forall (b a : fol.Formula L) (v0 v : nat) (s : fol.Term L),
fold_right max 0
(varFormula
(substituteFormula L b v
(fol.var L (newVar (v0 :: freeVarTerm L s ++ freeVarFormula L a))))) <=
pow3 (depth L b) + pow3 (depth L b) +
max v0
(max (fold_right max 0 (freeVarTerm L s))
(max v
(max (fold_right max 0 (varFormula b))
(fold_right max 0 (varFormula a))))).
Remark boundSubFormulaHelp :
forall (f : fol.Formula L) (v : nat) (s : fol.Term L),
codeFormula (substituteFormula L f v s) <=
ReplaceFormulaTerm (codeFormula f)
(max (codeTerm s)
(pow3 (depth L f) +
fold_right max 0 (v :: freeVarTerm L s ++ varFormula f))).
Definition boundComputation (d p1 p2 : nat) : nat :=
nat_rec (fun _ => nat) (cTriple p1 p2 0)
(fun _ rec : nat => cTriple p1 p2 (cPair rec rec)) d.

Lemma boundComputationIsPR : isPR 3 boundComputation.