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.

(* Specifications: *)
Lemma freeVarSubTerm1 :
forall (t : Term) (v : nat) (s : Term) (x : nat),
In x (freeVarTerm L t) ->
v <> x -> In x (freeVarTerm L (substituteTerm L t v s)).
Lemma freeVarSubTerms1 :
forall (n : nat) (ts : Terms n) (v : nat) (s : Term) (x : nat),
In x (freeVarTerms L n ts) ->
v <> x -> In x (freeVarTerms L n (substituteTerms L n ts v s)).
Lemma freeVarSubFormula1 :
forall (f : Formula) (v : nat) (s : Term) (x : nat),
v <> x ->
In x (freeVarFormula L f) ->
In x (freeVarFormula L (substituteFormula L f v s)).
Lemma freeVarSubTerm2 :
forall (t : Term) (v : nat) (s : Term) (x : nat),
In x (freeVarTerm L s) ->
In v (freeVarTerm L t) -> In x (freeVarTerm L (substituteTerm L t v s)).
Lemma freeVarSubTerms2 :
forall (n : nat) (ts : Terms n) (v : nat) (s : Term) (x : nat),
In x (freeVarTerm L s) ->
In v (freeVarTerms L n ts) ->
In x (freeVarTerms L n (substituteTerms L n ts v s)).
Lemma freeVarSubFormula2 :
forall (f : Formula) (v : nat) (s : Term) (x : nat),
In x (freeVarTerm L s) ->
In v (freeVarFormula L f) ->
In x (freeVarFormula L (substituteFormula L f v s)).
Lemma freeVarSubTerm3 :
forall (t : Term) (v : nat) (s : Term) (x : nat),
In x (freeVarTerm L (substituteTerm L t v s)) ->
In x (list_remove _ eq_nat_dec v (freeVarTerm L t)) \/
In x (freeVarTerm L s).
Lemma freeVarSubTerms3 :
forall (n : nat) (ts : fol.Terms L n) (v : nat) (s : Term) (x : nat),
In x (freeVarTerms L n (substituteTerms L n ts v s)) ->
In x (list_remove _ eq_nat_dec v (freeVarTerms L n ts)) \/
In x (freeVarTerm L s).
Lemma freeVarSubFormula3 :
forall (f : Formula) (v : nat) (s : Term) (x : nat),
In x (freeVarFormula L (substituteFormula L f v s)) ->
In x (list_remove _ eq_nat_dec v (freeVarFormula L f)) \/
In x (freeVarTerm L s).
Lemma freeVarSubTerm4 :
forall (t : Term) (v : nat) (s : Term) (x : nat),
In x (freeVarTerm L (substituteTerm L t v s)) ->
~ In v (freeVarTerm L t) -> In x (freeVarTerm L t).
Lemma freeVarSubTerms4 :
forall (n : nat) (ts : Terms n) (v : nat) (s : Term) (x : nat),
In x (freeVarTerms L n (substituteTerms L n ts v s)) ->
~ In v (freeVarTerms L n ts) -> In x (freeVarTerms L n ts).
Lemma freeVarSubFormula4 :
forall (f : Formula) (v : nat) (s : Term) (x : nat),
In x (freeVarFormula L (substituteFormula L f v s)) ->
~ In v (freeVarFormula L f) -> In x (freeVarFormula L f).
Lemma subTermNil :
forall (t : Term) (v : nat) (s : Term),
~ In v (freeVarTerm L t) -> substituteTerm L t v s = t.
Lemma subTermTrans :
forall (t : Term) (v1 v2 : nat) (s : Term),
~ In v2 (list_remove _ eq_nat_dec v1 (freeVarTerm L t)) ->
substituteTerm L (substituteTerm L t v1 (var v2)) v2 s =
substituteTerm L t v1 s.
Lemma subTermExch :
forall (t : Term) (v1 v2 : nat) (s1 s2 : Term),
v1 <> v2 ->
~ In v2 (freeVarTerm L s1) ->
~ In v1 (freeVarTerm L s2) ->
substituteTerm L (substituteTerm L t v1 s1) v2 s2 =
substituteTerm L (substituteTerm L t v2 s2) v1 s1.
Lemma subTermsNil :
forall (n : nat) (ts : Terms n) (v : nat) (s : Term),
~ In v (freeVarTerms L n ts) -> substituteTerms L n ts v s = ts.
Lemma subTermsTrans :
forall (n : nat) (ts : Terms n) (v1 v2 : nat) (s : Term),
~ In v2 (list_remove _ eq_nat_dec v1 (freeVarTerms L n ts)) ->
substituteTerms L n (substituteTerms L n ts v1 (var v2)) v2 s =
substituteTerms L n ts v1 s.
Lemma subTermsExch :
forall (n : nat) (ts : Terms n) (v1 v2 : nat) (s1 s2 : Term),
v1 <> v2 ->
~ In v2 (freeVarTerm L s1) ->
~ In v1 (freeVarTerm L s2) ->
substituteTerms L n (substituteTerms L n ts v1 s1) v2 s2 =
substituteTerms L n (substituteTerms L n ts v2 s2) v1 s1.