Section Substitution_Properties.
Variable L : Language.
Let Formula := Formula L.
Let Formulas := Formulas L.
Let System := System L.
Let Term := Term L.
Let Terms := Terms L.
Let var := var L.
Let apply := apply L.
Let equal := equal L.
Let atomic := atomic L.
Let impH := impH L.
Let notH := notH L.
Let forallH := forallH L.
Let orH := orH L.
Let andH := andH L.
Let existH := existH L.
Let iffH := iffH L.
Let SysPrf := SysPrf L.
Remark subFormulaNTEHelp :
forall (f g : Formula) (v : nat) (s : Term),
SysPrf (Ensembles.Add _ (Empty_set Formula) f) g ->
SysPrf (Ensembles.Add _ (Empty_set Formula) (substituteFormula L f v s))
(substituteFormula L g v s).
Remark subFormulaNTE :
forall (f : Formula) (T : System),
(forall (v : nat) (s : Term),
~ In v (freeVarFormula L f) ->
SysPrf T (iffH (substituteFormula L f v s) f)) /\
(forall (v1 v2 : nat) (s : Term),
~ In v2 (list_remove _ eq_nat_dec v1 (freeVarFormula L f)) ->
SysPrf T
(iffH (substituteFormula L (substituteFormula L f v1 (var v2)) v2 s)
(substituteFormula L f v1 s))) /\
(forall (v1 v2 : nat) (s1 s2 : Term),
v1 <> v2 ->
~ In v2 (freeVarTerm L s1) ->
~ In v1 (freeVarTerm L s2) ->
SysPrf T
(iffH (substituteFormula L (substituteFormula L f v1 s1) v2 s2)
(substituteFormula L (substituteFormula L f v2 s2) v1 s1))).

Lemma subFormulaTrans :
forall (f : Formula) (T : System) (v1 v2 : nat) (s : Term),
~ In v2 (list_remove _ eq_nat_dec v1 (freeVarFormula L f)) ->
SysPrf T
(iffH (substituteFormula L (substituteFormula L f v1 (var v2)) v2 s)
(substituteFormula L f v1 s)).