Section SubAllVars.
Variable L : Language.
Notation Formula := (Formula L) (only parsing).
Notation Formulas := (Formulas L) (only parsing).
Notation System := (System L) (only parsing).
Notation Term := (Term L) (only parsing).
Notation Terms := (Terms L) (only parsing).
Notation var := (var L) (only parsing).
Notation apply := (apply L) (only parsing).
Notation equal := (equal L) (only parsing).
Notation atomic := (atomic L) (only parsing).
Notation impH := (impH L) (only parsing).
Notation notH := (notH L) (only parsing).
Notation forallH := (forallH L) (only parsing).
Notation iffH := (iffH L) (only parsing).
Notation SysPrf := (SysPrf L) (only parsing).
Fixpoint subAllTerm (t : fol.Term L) : (nat -> fol.Term L) -> fol.Term L :=
match t return ((nat -> fol.Term L) -> fol.Term L) with
| fol.var x => fun m => m x
| fol.apply f ts => fun m => fol.apply L f (subAllTerms _ ts m)
end
with subAllTerms (n : nat) (ts : fol.Terms L n) {struct ts} :
(nat -> fol.Term L) -> fol.Terms L n :=
match
ts in (fol.Terms _ n) return ((nat -> fol.Term L) -> fol.Terms L n)
with
| Tnil => fun _ => Tnil L
| Tcons n' t ss =>
fun m => Tcons L n' (subAllTerm t m) (subAllTerms _ ss m)
end.

Lemma subAllTerm_ext :
forall (t : fol.Term L) (m1 m2 : nat -> fol.Term L),
(forall m : nat, In m (freeVarTerm L t) -> m1 m = m2 m) ->
subAllTerm t m1 = subAllTerm t m2.