Fixpoint varFormula (f : fol.Formula L) : list nat :=
  match f with
  | equal t s => freeVarTerm L t ++ freeVarTerm L s
  | atomic r ts => freeVarTerms L _ ts
  | impH A B => varFormula A ++ varFormula B
  | notH A => varFormula A
  | forallH v A => v :: varFormula A
  end.

(* Specifications: *)
Lemma ReplaceFormulaTermSub : forall (f : fol.Formula L) (v w s2 : nat), ReplaceFormulaTerm (codeFormula (substituteFormula L f v (var w))) s2 = ReplaceFormulaTerm (codeFormula f) s2.