:: SUBSTUT1 semantic presentation

definition
func vSUB -> set equals :: SUBSTUT1:def 1
PFuncs bound_QC-variables ,bound_QC-variables ;
coherence
PFuncs bound_QC-variables ,bound_QC-variables is set
;
end;

:: deftheorem Def1 defines vSUB SUBSTUT1:def 1 :
vSUB = PFuncs bound_QC-variables ,bound_QC-variables ;

registration
cluster vSUB -> non empty ;
coherence
not vSUB is empty
;
end;

definition
mode CQC_Substitution is Element of vSUB ;
end;

registration
cluster vSUB -> non empty functional ;
coherence
vSUB is functional
;
end;

definition
let c1 be CQC_Substitution;
func @ c1 -> PartFunc of bound_QC-variables , bound_QC-variables equals :: SUBSTUT1:def 2
a1;
coherence
c1 is PartFunc of bound_QC-variables , bound_QC-variables
by PARTFUN1:121;
end;

:: deftheorem Def2 defines @ SUBSTUT1:def 2 :
for b1 being CQC_Substitution holds @ b1 = b1;

theorem Th1: :: SUBSTUT1:1
for b1 being set
for b2 being CQC_Substitution st b1 in dom b2 holds
b2 . b1 in bound_QC-variables
proof end;

definition
let c1 be FinSequence of QC-variables ;
let c2 be CQC_Substitution;
func CQC_Subst c1,c2 -> FinSequence of QC-variables means :Def3: :: SUBSTUT1:def 3
( len a3 = len a1 & ( for b1 being Nat st 1 <= b1 & b1 <= len a1 holds
( ( a1 . b1 in dom a2 implies a3 . b1 = a2 . (a1 . b1) ) & ( not a1 . b1 in dom a2 implies a3 . b1 = a1 . b1 ) ) ) );
existence
ex b1 being FinSequence of QC-variables st
( len b1 = len c1 & ( for b2 being Nat st 1 <= b2 & b2 <= len c1 holds
( ( c1 . b2 in dom c2 implies b1 . b2 = c2 . (c1 . b2) ) & ( not c1 . b2 in dom c2 implies b1 . b2 = c1 . b2 ) ) ) )
proof end;
uniqueness
for b1, b2 being FinSequence of QC-variables st len b1 = len c1 & ( for b3 being Nat st 1 <= b3 & b3 <= len c1 holds
( ( c1 . b3 in dom c2 implies b1 . b3 = c2 . (c1 . b3) ) & ( not c1 . b3 in dom c2 implies b1 . b3 = c1 . b3 ) ) ) & len b2 = len c1 & ( for b3 being Nat st 1 <= b3 & b3 <= len c1 holds
( ( c1 . b3 in dom c2 implies b2 . b3 = c2 . (c1 . b3) ) & ( not c1 . b3 in dom c2 implies b2 . b3 = c1 . b3 ) ) ) holds
b1 = b2
proof end;
end;

:: deftheorem Def3 defines CQC_Subst SUBSTUT1:def 3 :
for b1 being FinSequence of QC-variables
for b2 being CQC_Substitution
for b3 being FinSequence of QC-variables holds
( b3 = CQC_Subst b1,b2 iff ( len b3 = len b1 & ( for b4 being Nat st 1 <= b4 & b4 <= len b1 holds
( ( b1 . b4 in dom b2 implies b3 . b4 = b2 . (b1 . b4) ) & ( not b1 . b4 in dom b2 implies b3 . b4 = b1 . b4 ) ) ) ) );

definition
let c1 be FinSequence of bound_QC-variables ;
func @ c1 -> FinSequence of QC-variables equals :: SUBSTUT1:def 4
a1;
coherence
c1 is FinSequence of QC-variables
proof end;
end;

:: deftheorem Def4 defines @ SUBSTUT1:def 4 :
for b1 being FinSequence of bound_QC-variables holds @ b1 = b1;

definition
let c1 be FinSequence of bound_QC-variables ;
let c2 be CQC_Substitution;
func CQC_Subst c1,c2 -> FinSequence of bound_QC-variables equals :: SUBSTUT1:def 5
CQC_Subst (@ a1),a2;
coherence
CQC_Subst (@ c1),c2 is FinSequence of bound_QC-variables
proof end;
end;

:: deftheorem Def5 defines CQC_Subst SUBSTUT1:def 5 :
for b1 being FinSequence of bound_QC-variables
for b2 being CQC_Substitution holds CQC_Subst b1,b2 = CQC_Subst (@ b1),b2;

definition
let c1 be CQC_Substitution;
let c2 be set ;
redefine func | as c1 | c2 -> CQC_Substitution;
coherence
c1 | c2 is CQC_Substitution
proof end;
end;

registration
cluster finite Element of vSUB ;
existence
ex b1 being CQC_Substitution st b1 is finite
proof end;
end;

definition
let c1 be bound_QC-variable;
let c2 be QC-formula;
let c3 be CQC_Substitution;
func RestrictSub c1,c2,c3 -> finite CQC_Substitution equals :: SUBSTUT1:def 6
a3 | { b1 where B is bound_QC-variable : ( b1 in still_not-bound_in a2 & b1 is Element of dom a3 & b1 <> a1 & b1 <> a3 . b1 ) } ;
coherence
c3 | { b1 where B is bound_QC-variable : ( b1 in still_not-bound_in c2 & b1 is Element of dom c3 & b1 <> c1 & b1 <> c3 . b1 ) } is finite CQC_Substitution
proof end;
end;

:: deftheorem Def6 defines RestrictSub SUBSTUT1:def 6 :
for b1 being bound_QC-variable
for b2 being QC-formula
for b3 being CQC_Substitution holds RestrictSub b1,b2,b3 = b3 | { b4 where B is bound_QC-variable : ( b4 in still_not-bound_in b2 & b4 is Element of dom b3 & b4 <> b1 & b4 <> b3 . b4 ) } ;

definition
let c1 be FinSequence of QC-variables ;
func Bound_Vars c1 -> Subset of bound_QC-variables equals :: SUBSTUT1:def 7
{ (a1 . b1) where B is Nat : ( 1 <= b1 & b1 <= len a1 & a1 . b1 in bound_QC-variables ) } ;
coherence
{ (c1 . b1) where B is Nat : ( 1 <= b1 & b1 <= len c1 & c1 . b1 in bound_QC-variables ) } is Subset of bound_QC-variables
proof end;
end;

:: deftheorem Def7 defines Bound_Vars SUBSTUT1:def 7 :
for b1 being FinSequence of QC-variables holds Bound_Vars b1 = { (b1 . b2) where B is Nat : ( 1 <= b2 & b2 <= len b1 & b1 . b2 in bound_QC-variables ) } ;

definition
let c1 be QC-formula;
func Bound_Vars c1 -> Subset of bound_QC-variables means :Def8: :: SUBSTUT1:def 8
ex b1 being Function of QC-WFF , bool bound_QC-variables st
( a2 = b1 . a1 & ( for b2 being Element of QC-WFF
for b3, b4 being Subset of bound_QC-variables holds
( ( b2 = VERUM implies b1 . b2 = {} bound_QC-variables ) & ( b2 is atomic implies b1 . b2 = Bound_Vars (the_arguments_of b2) ) & ( b2 is negative & b3 = b1 . (the_argument_of b2) implies b1 . b2 = b3 ) & ( b2 is conjunctive & b3 = b1 . (the_left_argument_of b2) & b4 = b1 . (the_right_argument_of b2) implies b1 . b2 = b3 \/ b4 ) & ( b2 is universal & b3 = b1 . (the_scope_of b2) implies b1 . b2 = b3 \/ {(bound_in b2)} ) ) ) );
correctness
existence
ex b1 being Subset of bound_QC-variables ex b2 being Function of QC-WFF , bool bound_QC-variables st
( b1 = b2 . c1 & ( for b3 being Element of QC-WFF
for b4, b5 being Subset of bound_QC-variables holds
( ( b3 = VERUM implies b2 . b3 = {} bound_QC-variables ) & ( b3 is atomic implies b2 . b3 = Bound_Vars (the_arguments_of b3) ) & ( b3 is negative & b4 = b2 . (the_argument_of b3) implies b2 . b3 = b4 ) & ( b3 is conjunctive & b4 = b2 . (the_left_argument_of b3) & b5 = b2 . (the_right_argument_of b3) implies b2 . b3 = b4 \/ b5 ) & ( b3 is universal & b4 = b2 . (the_scope_of b3) implies b2 . b3 = b4 \/ {(bound_in b3)} ) ) ) )
;
uniqueness
for b1, b2 being Subset of bound_QC-variables st ex b3 being Function of QC-WFF , bool bound_QC-variables st
( b1 = b3 . c1 & ( for b4 being Element of QC-WFF
for b5, b6 being Subset of bound_QC-variables holds
( ( b4 = VERUM implies b3 . b4 = {} bound_QC-variables ) & ( b4 is atomic implies b3 . b4 = Bound_Vars (the_arguments_of b4) ) & ( b4 is negative & b5 = b3 . (the_argument_of b4) implies b3 . b4 = b5 ) & ( b4 is conjunctive & b5 = b3 . (the_left_argument_of b4) & b6 = b3 . (the_right_argument_of b4) implies b3 . b4 = b5 \/ b6 ) & ( b4 is universal & b5 = b3 . (the_scope_of b4) implies b3 . b4 = b5 \/ {(bound_in b4)} ) ) ) ) & ex b3 being Function of QC-WFF , bool bound_QC-variables st
( b2 = b3 . c1 & ( for b4 being Element of QC-WFF
for b5, b6 being Subset of bound_QC-variables holds
( ( b4 = VERUM implies b3 . b4 = {} bound_QC-variables ) & ( b4 is atomic implies b3 . b4 = Bound_Vars (the_arguments_of b4) ) & ( b4 is negative & b5 = b3 . (the_argument_of b4) implies b3 . b4 = b5 ) & ( b4 is conjunctive & b5 = b3 . (the_left_argument_of b4) & b6 = b3 . (the_right_argument_of b4) implies b3 . b4 = b5 \/ b6 ) & ( b4 is universal & b5 = b3 . (the_scope_of b4) implies b3 . b4 = b5 \/ {(bound_in b4)} ) ) ) ) holds
b1 = b2
;
proof end;
end;

:: deftheorem Def8 defines Bound_Vars SUBSTUT1:def 8 :
for b1 being QC-formula
for b2 being Subset of bound_QC-variables holds
( b2 = Bound_Vars b1 iff ex b3 being Function of QC-WFF , bool bound_QC-variables st
( b2 = b3 . b1 & ( for b4 being Element of QC-WFF
for b5, b6 being Subset of bound_QC-variables holds
( ( b4 = VERUM implies b3 . b4 = {} bound_QC-variables ) & ( b4 is atomic implies b3 . b4 = Bound_Vars (the_arguments_of b4) ) & ( b4 is negative & b5 = b3 . (the_argument_of b4) implies b3 . b4 = b5 ) & ( b4 is conjunctive & b5 = b3 . (the_left_argument_of b4) & b6 = b3 . (the_right_argument_of b4) implies b3 . b4 = b5 \/ b6 ) & ( b4 is universal & b5 = b3 . (the_scope_of b4) implies b3 . b4 = b5 \/ {(bound_in b4)} ) ) ) ) );

Lemma4: for b1 being QC-formula holds
( Bound_Vars VERUM = {} bound_QC-variables & ( b1 is atomic implies Bound_Vars b1 = Bound_Vars (the_arguments_of b1) ) & ( b1 is negative implies Bound_Vars b1 = Bound_Vars (the_argument_of b1) ) & ( b1 is conjunctive implies Bound_Vars b1 = (Bound_Vars (the_left_argument_of b1)) \/ (Bound_Vars (the_right_argument_of b1)) ) & ( b1 is universal implies Bound_Vars b1 = (Bound_Vars (the_scope_of b1)) \/ {(bound_in b1)} ) )
proof end;

theorem Th2: :: SUBSTUT1:2
Bound_Vars VERUM = {} by Lemma4;

theorem Th3: :: SUBSTUT1:3
for b1 being QC-formula st b1 is atomic holds
Bound_Vars b1 = Bound_Vars (the_arguments_of b1) by Lemma4;

theorem Th4: :: SUBSTUT1:4
for b1 being QC-formula st b1 is negative holds
Bound_Vars b1 = Bound_Vars (the_argument_of b1) by Lemma4;

theorem Th5: :: SUBSTUT1:5
for b1 being QC-formula st b1 is conjunctive holds
Bound_Vars b1 = (Bound_Vars (the_left_argument_of b1)) \/ (Bound_Vars (the_right_argument_of b1)) by Lemma4;

theorem Th6: :: SUBSTUT1:6
for b1 being QC-formula st b1 is universal holds
Bound_Vars b1 = (Bound_Vars (the_scope_of b1)) \/ {(bound_in b1)} by Lemma4;

registration
let c1 be QC-formula;
cluster Bound_Vars a1 -> finite ;
coherence
Bound_Vars c1 is finite
proof end;
end;

definition
let c1 be QC-formula;
func Dom_Bound_Vars c1 -> finite Subset of NAT equals :: SUBSTUT1:def 9
{ b1 where B is Nat : x. b1 in Bound_Vars a1 } ;
coherence
{ b1 where B is Nat : x. b1 in Bound_Vars c1 } is finite Subset of NAT
proof end;
end;

:: deftheorem Def9 defines Dom_Bound_Vars SUBSTUT1:def 9 :
for b1 being QC-formula holds Dom_Bound_Vars b1 = { b2 where B is Nat : x. b2 in Bound_Vars b1 } ;

definition
let c1 be finite CQC_Substitution;
func Sub_Var c1 -> finite Subset of NAT equals :: SUBSTUT1:def 10
{ b1 where B is Nat : x. b1 in rng a1 } ;
coherence
{ b1 where B is Nat : x. b1 in rng c1 } is finite Subset of NAT
proof end;
end;

:: deftheorem Def10 defines Sub_Var SUBSTUT1:def 10 :
for b1 being finite CQC_Substitution holds Sub_Var b1 = { b2 where B is Nat : x. b2 in rng b1 } ;

definition
let c1 be QC-formula;
let c2 be finite CQC_Substitution;
func NSub c1,c2 -> non empty Subset of NAT equals :: SUBSTUT1:def 11
NAT \ ((Dom_Bound_Vars a1) \/ (Sub_Var a2));
coherence
NAT \ ((Dom_Bound_Vars c1) \/ (Sub_Var c2)) is non empty Subset of NAT
proof end;
end;

:: deftheorem Def11 defines NSub SUBSTUT1:def 11 :
for b1 being QC-formula
for b2 being finite CQC_Substitution holds NSub b1,b2 = NAT \ ((Dom_Bound_Vars b1) \/ (Sub_Var b2));

definition
let c1 be finite CQC_Substitution;
let c2 be QC-formula;
func upVar c1,c2 -> Nat equals :: SUBSTUT1:def 12
min (NSub a2,a1);
coherence
min (NSub c2,c1) is Nat
;
end;

:: deftheorem Def12 defines upVar SUBSTUT1:def 12 :
for b1 being finite CQC_Substitution
for b2 being QC-formula holds upVar b1,b2 = min (NSub b2,b1);

definition
let c1 be bound_QC-variable;
let c2 be QC-formula;
let c3 be finite CQC_Substitution;
assume E5: ex b1 being CQC_Substitution st c3 = RestrictSub c1,(All c1,c2),b1 ;
func ExpandSub c1,c2,c3 -> CQC_Substitution equals :: SUBSTUT1:def 13
a3 \/ {[a1,(x. (upVar a3,a2))]} if a1 in rng a3
otherwise a3 \/ {[a1,a1]};
coherence
( ( c1 in rng c3 implies c3 \/ {[c1,(x. (upVar c3,c2))]} is CQC_Substitution ) & ( not c1 in rng c3 implies c3 \/ {[c1,c1]} is CQC_Substitution ) )
proof end;
consistency
for b1 being CQC_Substitution holds verum
;
end;

:: deftheorem Def13 defines ExpandSub SUBSTUT1:def 13 :
for b1 being bound_QC-variable
for b2 being QC-formula
for b3 being finite CQC_Substitution st ex b4 being CQC_Substitution st b3 = RestrictSub b1,(All b1,b2),b4 holds
( ( b1 in rng b3 implies ExpandSub b1,b2,b3 = b3 \/ {[b1,(x. (upVar b3,b2))]} ) & ( not b1 in rng b3 implies ExpandSub b1,b2,b3 = b3 \/ {[b1,b1]} ) );

definition
let c1 be QC-formula;
let c2 be CQC_Substitution;
let c3 be set ;
pred c1,c2 PQSub c3 means :Def14: :: SUBSTUT1:def 14
( ( a1 is universal implies a3 = ExpandSub (bound_in a1),(the_scope_of a1),(RestrictSub (bound_in a1),a1,a2) ) & ( not a1 is universal implies a3 = {} ) );
end;

:: deftheorem Def14 defines PQSub SUBSTUT1:def 14 :
for b1 being QC-formula
for b2 being CQC_Substitution
for b3 being set holds
( b1,b2 PQSub b3 iff ( ( b1 is universal implies b3 = ExpandSub (bound_in b1),(the_scope_of b1),(RestrictSub (bound_in b1),b1,b2) ) & ( not b1 is universal implies b3 = {} ) ) );

definition
func QSub -> Function means :: SUBSTUT1:def 15
for b1 being set holds
( b1 in a1 iff ex b2 being QC-formulaex b3 being CQC_Substitutionex b4 being set st
( b1 = [[b2,b3],b4] & b2,b3 PQSub b4 ) );
existence
ex b1 being Function st
for b2 being set holds
( b2 in b1 iff ex b3 being QC-formulaex b4 being CQC_Substitutionex b5 being set st
( b2 = [[b3,b4],b5] & b3,b4 PQSub b5 ) )
proof end;
uniqueness
for b1, b2 being Function st ( for b3 being set holds
( b3 in b1 iff ex b4 being QC-formulaex b5 being CQC_Substitutionex b6 being set st
( b3 = [[b4,b5],b6] & b4,b5 PQSub b6 ) ) ) & ( for b3 being set holds
( b3 in b2 iff ex b4 being QC-formulaex b5 being CQC_Substitutionex b6 being set st
( b3 = [[b4,b5],b6] & b4,b5 PQSub b6 ) ) ) holds
b1 = b2
proof end;
end;

:: deftheorem Def15 defines QSub SUBSTUT1:def 15 :
for b1 being Function holds
( b1 = QSub iff for b2 being set holds
( b2 in b1 iff ex b3 being QC-formulaex b4 being CQC_Substitutionex b5 being set st
( b2 = [[b3,b4],b5] & b3,b4 PQSub b5 ) ) );

theorem Th7: :: SUBSTUT1:7
( [:QC-WFF ,vSUB :] is Subset of [:([:NAT ,NAT :] * ),vSUB :] & ( for b1 being Nat
for b2 being QC-pred_symbol of b1
for b3 being QC-variable_list of b1
for b4 being Element of vSUB holds [(<*b2*> ^ b3),b4] in [:QC-WFF ,vSUB :] ) & ( for b1 being Element of vSUB holds [<*[0,0]*>,b1] in [:QC-WFF ,vSUB :] ) & ( for b1 being FinSequence of [:NAT ,NAT :]
for b2 being Element of vSUB st [b1,b2] in [:QC-WFF ,vSUB :] holds
[(<*[1,0]*> ^ b1),b2] in [:QC-WFF ,vSUB :] ) & ( for b1, b2 being FinSequence of [:NAT ,NAT :]
for b3 being Element of vSUB st [b1,b3] in [:QC-WFF ,vSUB :] & [b2,b3] in [:QC-WFF ,vSUB :] holds
[((<*[2,0]*> ^ b1) ^ b2),b3] in [:QC-WFF ,vSUB :] ) & ( for b1 being bound_QC-variable
for b2 being FinSequence of [:NAT ,NAT :]
for b3 being Element of vSUB st [b2,(QSub . [((<*[3,0]*> ^ <*b1*>) ^ b2),b3])] in [:QC-WFF ,vSUB :] holds
[((<*[3,0]*> ^ <*b1*>) ^ b2),b3] in [:QC-WFF ,vSUB :] ) )
proof end;

definition
let c1 be set ;
attr a1 is QC-Sub-closed means :Def16: :: SUBSTUT1:def 16
( a1 is Subset of [:([:NAT ,NAT :] * ),vSUB :] & ( for b1 being Nat
for b2 being QC-pred_symbol of b1
for b3 being QC-variable_list of b1
for b4 being Element of vSUB holds [(<*b2*> ^ b3),b4] in a1 ) & ( for b1 being Element of vSUB holds [<*[0,0]*>,b1] in a1 ) & ( for b1 being FinSequence of [:NAT ,NAT :]
for b2 being Element of vSUB st [b1,b2] in a1 holds
[(<*[1,0]*> ^ b1),b2] in a1 ) & ( for b1, b2 being FinSequence of [:NAT ,NAT :]
for b3 being Element of vSUB st [b1,b3] in a1 & [b2,b3] in a1 holds
[((<*[2,0]*> ^ b1) ^ b2),b3] in a1 ) & ( for b1 being bound_QC-variable
for b2 being FinSequence of [:NAT ,NAT :]
for b3 being Element of vSUB st [b2,(QSub . [((<*[3,0]*> ^ <*b1*>) ^ b2),b3])] in a1 holds
[((<*[3,0]*> ^ <*b1*>) ^ b2),b3] in a1 ) );
end;

:: deftheorem Def16 defines QC-Sub-closed SUBSTUT1:def 16 :
for b1 being set holds
( b1 is QC-Sub-closed iff ( b1 is Subset of [:([:NAT ,NAT :] * ),vSUB :] & ( for b2 being Nat
for b3 being QC-pred_symbol of b2
for b4 being QC-variable_list of b2
for b5 being Element of vSUB holds [(<*b3*> ^ b4),b5] in b1 ) & ( for b2 being Element of vSUB holds [<*[0,0]*>,b2] in b1 ) & ( for b2 being FinSequence of [:NAT ,NAT :]
for b3 being Element of vSUB st [b2,b3] in b1 holds
[(<*[1,0]*> ^ b2),b3] in b1 ) & ( for b2, b3 being FinSequence of [:NAT ,NAT :]
for b4 being Element of vSUB st [b2,b4] in b1 & [b3,b4] in b1 holds
[((<*[2,0]*> ^ b2) ^ b3),b4] in b1 ) & ( for b2 being bound_QC-variable
for b3 being FinSequence of [:NAT ,NAT :]
for b4 being Element of vSUB st [b3,(QSub . [((<*[3,0]*> ^ <*b2*>) ^ b3),b4])] in b1 holds
[((<*[3,0]*> ^ <*b2*>) ^ b3),b4] in b1 ) ) );

registration
cluster non empty QC-Sub-closed set ;
existence
ex b1 being set st
( b1 is QC-Sub-closed & not b1 is empty )
proof end;
end;

Lemma8: for b1 being bound_QC-variable
for b2 being FinSequence of [:NAT ,NAT :] holds (<*[3,0]*> ^ <*b1*>) ^ b2 is FinSequence of [:NAT ,NAT :]
proof end;

Lemma9: for b1, b2 being Nat
for b3 being Element of vSUB holds [<*[b1,b2]*>,b3] in [:([:NAT ,NAT :] * ),vSUB :]
proof end;

Lemma10: for b1 being Nat
for b2 being QC-pred_symbol of b1
for b3 being QC-variable_list of b1
for b4 being Element of vSUB holds [(<*b2*> ^ b3),b4] in [:([:NAT ,NAT :] * ),vSUB :]
proof end;

definition
func QC-Sub-WFF -> non empty set means :Def17: :: SUBSTUT1:def 17
( a1 is QC-Sub-closed & ( for b1 being non empty set st b1 is QC-Sub-closed holds
a1 c= b1 ) );
existence
ex b1 being non empty set st
( b1 is QC-Sub-closed & ( for b2 being non empty set st b2 is QC-Sub-closed holds
b1 c= b2 ) )
proof end;
uniqueness
for b1, b2 being non empty set st b1 is QC-Sub-closed & ( for b3 being non empty set st b3 is QC-Sub-closed holds
b1 c= b3 ) & b2 is QC-Sub-closed & ( for b3 being non empty set st b3 is QC-Sub-closed holds
b2 c= b3 ) holds
b1 = b2
proof end;
end;

:: deftheorem Def17 defines QC-Sub-WFF SUBSTUT1:def 17 :
for b1 being non empty set holds
( b1 = QC-Sub-WFF iff ( b1 is QC-Sub-closed & ( for b2 being non empty set st b2 is QC-Sub-closed holds
b1 c= b2 ) ) );

theorem Th8: :: SUBSTUT1:8
for b1 being Element of QC-Sub-WFF ex b2 being QC-formulaex b3 being Element of vSUB st b1 = [b2,b3]
proof end;

registration
cluster QC-Sub-WFF -> non empty QC-Sub-closed ;
coherence
QC-Sub-WFF is QC-Sub-closed
by Def17;
end;

definition
let c1 be QC-pred_symbol;
let c2 be FinSequence of QC-variables ;
let c3 be Element of vSUB ;
assume E13: the_arity_of c1 = len c2 ;
func Sub_P c1,c2,c3 -> Element of QC-Sub-WFF equals :Def18: :: SUBSTUT1:def 18
[(a1 ! a2),a3];
coherence
[(c1 ! c2),c3] is Element of QC-Sub-WFF
proof end;
end;

:: deftheorem Def18 defines Sub_P SUBSTUT1:def 18 :
for b1 being QC-pred_symbol
for b2 being FinSequence of QC-variables
for b3 being Element of vSUB st the_arity_of b1 = len b2 holds
Sub_P b1,b2,b3 = [(b1 ! b2),b3];

theorem Th9: :: SUBSTUT1:9
for b1 being Element of vSUB
for b2 being Nat
for b3 being QC-pred_symbol of b2
for b4 being QC-variable_list of b2 holds Sub_P b3,b4,b1 = [(b3 ! b4),b1]
proof end;

definition
let c1 be Element of QC-Sub-WFF ;
attr a1 is Sub_VERUM means :Def19: :: SUBSTUT1:def 19
ex b1 being Element of vSUB st a1 = [VERUM ,b1];
end;

:: deftheorem Def19 defines Sub_VERUM SUBSTUT1:def 19 :
for b1 being Element of QC-Sub-WFF holds
( b1 is Sub_VERUM iff ex b2 being Element of vSUB st b1 = [VERUM ,b2] );

definition
let c1 be Element of QC-Sub-WFF ;
redefine func `1 as c1 `1 -> Element of QC-WFF ;
coherence
c1 `1 is Element of QC-WFF
proof end;
redefine func `2 as c1 `2 -> Element of vSUB ;
coherence
c1 `2 is Element of vSUB
proof end;
end;

theorem Th10: :: SUBSTUT1:10
for b1 being Element of QC-Sub-WFF holds b1 = [(b1 `1 ),(b1 `2 )]
proof end;

definition
let c1 be Element of QC-Sub-WFF ;
func Sub_not c1 -> Element of QC-Sub-WFF equals :: SUBSTUT1:def 20
[('not' (a1 `1 )),(a1 `2 )];
coherence
[('not' (c1 `1 )),(c1 `2 )] is Element of QC-Sub-WFF
proof end;
end;

:: deftheorem Def20 defines Sub_not SUBSTUT1:def 20 :
for b1 being Element of QC-Sub-WFF holds Sub_not b1 = [('not' (b1 `1 )),(b1 `2 )];

definition
let c1, c2 be Element of QC-Sub-WFF ;
assume E17: c1 `2 = c2 `2 ;
func Sub_& c1,c2 -> Element of QC-Sub-WFF equals :Def21: :: SUBSTUT1:def 21
[((a1 `1 ) '&' (a2 `1 )),(a1 `2 )];
coherence
[((c1 `1 ) '&' (c2 `1 )),(c1 `2 )] is Element of QC-Sub-WFF
proof end;
end;

:: deftheorem Def21 defines Sub_& SUBSTUT1:def 21 :
for b1, b2 being Element of QC-Sub-WFF st b1 `2 = b2 `2 holds
Sub_& b1,b2 = [((b1 `1 ) '&' (b2 `1 )),(b1 `2 )];

definition
let c1 be Element of [:QC-Sub-WFF ,bound_QC-variables :];
redefine func `1 as c1 `1 -> Element of QC-Sub-WFF ;
coherence
c1 `1 is Element of QC-Sub-WFF
by MCART_1:10;
redefine func `2 as c1 `2 -> Element of bound_QC-variables ;
coherence
c1 `2 is Element of bound_QC-variables
by MCART_1:10;
end;

definition
let c1 be Element of [:QC-Sub-WFF ,bound_QC-variables :];
attr a1 is quantifiable means :Def22: :: SUBSTUT1:def 22
ex b1 being Element of vSUB st (a1 `1 ) `2 = QSub . [(All (a1 `2 ),((a1 `1 ) `1 )),b1];
end;

:: deftheorem Def22 defines quantifiable SUBSTUT1:def 22 :
for b1 being Element of [:QC-Sub-WFF ,bound_QC-variables :] holds
( b1 is quantifiable iff ex b2 being Element of vSUB st (b1 `1 ) `2 = QSub . [(All (b1 `2 ),((b1 `1 ) `1 )),b2] );

definition
let c1 be Element of [:QC-Sub-WFF ,bound_QC-variables :];
assume E19: c1 is quantifiable ;
mode second_Q_comp of c1 -> Element of vSUB means :Def23: :: SUBSTUT1:def 23
(a1 `1 ) `2 = QSub . [(All (a1 `2 ),((a1 `1 ) `1 )),a2];
existence
ex b1 being Element of vSUB st (c1 `1 ) `2 = QSub . [(All (c1 `2 ),((c1 `1 ) `1 )),b1]
by E19, Def22;
end;

:: deftheorem Def23 defines second_Q_comp SUBSTUT1:def 23 :
for b1 being Element of [:QC-Sub-WFF ,bound_QC-variables :] st b1 is quantifiable holds
for b2 being Element of vSUB holds
( b2 is second_Q_comp of b1 iff (b1 `1 ) `2 = QSub . [(All (b1 `2 ),((b1 `1 ) `1 )),b2] );

definition
let c1 be Element of [:QC-Sub-WFF ,bound_QC-variables :];
let c2 be second_Q_comp of c1;
assume E20: c1 is quantifiable ;
func Sub_All c1,c2 -> Element of QC-Sub-WFF equals :Def24: :: SUBSTUT1:def 24
[(All (a1 `2 ),((a1 `1 ) `1 )),a2];
coherence
[(All (c1 `2 ),((c1 `1 ) `1 )),c2] is Element of QC-Sub-WFF
proof end;
end;

:: deftheorem Def24 defines Sub_All SUBSTUT1:def 24 :
for b1 being Element of [:QC-Sub-WFF ,bound_QC-variables :]
for b2 being second_Q_comp of b1 st b1 is quantifiable holds
Sub_All b1,b2 = [(All (b1 `2 ),((b1 `1 ) `1 )),b2];

definition
let c1 be Element of QC-Sub-WFF ;
let c2 be bound_QC-variable;
redefine func [ as [c1,c2] -> Element of [:QC-Sub-WFF ,bound_QC-variables :];
coherence
[c1,c2] is Element of [:QC-Sub-WFF ,bound_QC-variables :]
proof end;
end;

scheme :: SUBSTUT1:sch 1
s1{ P1[ Element of QC-Sub-WFF ] } :
for b1 being Element of QC-Sub-WFF holds P1[b1]
provided
E21: for b1 being Nat
for b2 being QC-pred_symbol of b1
for b3 being QC-variable_list of b1
for b4 being Element of vSUB holds P1[ Sub_P b2,b3,b4] and
E22: for b1 being Element of QC-Sub-WFF st b1 is Sub_VERUM holds
P1[b1] and
E23: for b1 being Element of QC-Sub-WFF st P1[b1] holds
P1[ Sub_not b1] and
E24: for b1, b2 being Element of QC-Sub-WFF st b1 `2 = b2 `2 & P1[b1] & P1[b2] holds
P1[ Sub_& b1,b2] and
E25: for b1 being bound_QC-variable
for b2 being Element of QC-Sub-WFF
for b3 being second_Q_comp of [b2,b1] st [b2,b1] is quantifiable & P1[b2] holds
P1[ Sub_All [b2,b1],b3]
proof end;

definition
let c1 be Element of QC-Sub-WFF ;
attr a1 is Sub_atomic means :Def25: :: SUBSTUT1:def 25
ex b1 being Natex b2 being QC-pred_symbol of b1ex b3 being QC-variable_list of b1ex b4 being Element of vSUB st a1 = Sub_P b2,b3,b4;
end;

:: deftheorem Def25 defines Sub_atomic SUBSTUT1:def 25 :
for b1 being Element of QC-Sub-WFF holds
( b1 is Sub_atomic iff ex b2 being Natex b3 being QC-pred_symbol of b2ex b4 being QC-variable_list of b2ex b5 being Element of vSUB st b1 = Sub_P b3,b4,b5 );

theorem Th11: :: SUBSTUT1:11
for b1 being Element of QC-Sub-WFF st b1 is Sub_atomic holds
b1 `1 is atomic
proof end;

registration
let c1 be Nat;
let c2 be QC-pred_symbol of c1;
let c3 be QC-variable_list of c1;
let c4 be Element of vSUB ;
cluster Sub_P a2,a3,a4 -> Sub_atomic ;
coherence
Sub_P c2,c3,c4 is Sub_atomic
by Def25;
end;

definition
let c1 be Element of QC-Sub-WFF ;
attr a1 is Sub_negative means :Def26: :: SUBSTUT1:def 26
ex b1 being Element of QC-Sub-WFF st a1 = Sub_not b1;
attr a1 is Sub_conjunctive means :Def27: :: SUBSTUT1:def 27
ex b1, b2 being Element of QC-Sub-WFF st
( a1 = Sub_& b1,b2 & b1 `2 = b2 `2 );
end;

:: deftheorem Def26 defines Sub_negative SUBSTUT1:def 26 :
for b1 being Element of QC-Sub-WFF holds
( b1 is Sub_negative iff ex b2 being Element of QC-Sub-WFF st b1 = Sub_not b2 );

:: deftheorem Def27 defines Sub_conjunctive SUBSTUT1:def 27 :
for b1 being Element of QC-Sub-WFF holds
( b1 is Sub_conjunctive iff ex b2, b3 being Element of QC-Sub-WFF st
( b1 = Sub_& b2,b3 & b2 `2 = b3 `2 ) );

definition
let c1 be set ;
attr a1 is Sub_universal means :Def28: :: SUBSTUT1:def 28
ex b1 being Element of [:QC-Sub-WFF ,bound_QC-variables :]ex b2 being second_Q_comp of b1 st
( a1 = Sub_All b1,b2 & b1 is quantifiable );
end;

:: deftheorem Def28 defines Sub_universal SUBSTUT1:def 28 :
for b1 being set holds
( b1 is Sub_universal iff ex b2 being Element of [:QC-Sub-WFF ,bound_QC-variables :]ex b3 being second_Q_comp of b2 st
( b1 = Sub_All b2,b3 & b2 is quantifiable ) );

theorem Th12: :: SUBSTUT1:12
for b1 being Element of QC-Sub-WFF holds
( b1 is Sub_VERUM or b1 is Sub_atomic or b1 is Sub_negative or b1 is Sub_conjunctive or b1 is Sub_universal )
proof end;

definition
let c1 be Element of QC-Sub-WFF ;
assume E27: c1 is Sub_atomic ;
func Sub_the_arguments_of c1 -> FinSequence of QC-variables means :Def29: :: SUBSTUT1:def 29
ex b1 being Natex b2 being QC-pred_symbol of b1ex b3 being QC-variable_list of b1ex b4 being Element of vSUB st
( a2 = b3 & a1 = Sub_P b2,b3,b4 );
existence
ex b1 being FinSequence of QC-variables ex b2 being Natex b3 being QC-pred_symbol of b2ex b4 being QC-variable_list of b2ex b5 being Element of vSUB st
( b1 = b4 & c1 = Sub_P b3,b4,b5 )
proof end;
uniqueness
for b1, b2 being FinSequence of QC-variables st ex b3 being Natex b4 being QC-pred_symbol of b3ex b5 being QC-variable_list of b3ex b6 being Element of vSUB st
( b1 = b5 & c1 = Sub_P b4,b5,b6 ) & ex b3 being Natex b4 being QC-pred_symbol of b3ex b5 being QC-variable_list of b3ex b6 being Element of vSUB st
( b2 = b5 & c1 = Sub_P b4,b5,b6 ) holds
b1 = b2
proof end;
end;

:: deftheorem Def29 defines Sub_the_arguments_of SUBSTUT1:def 29 :
for b1 being Element of QC-Sub-WFF st b1 is Sub_atomic holds
for b2 being FinSequence of QC-variables holds
( b2 = Sub_the_arguments_of b1 iff ex b3 being Natex b4 being QC-pred_symbol of b3ex b5 being QC-variable_list of b3ex b6 being Element of vSUB st
( b2 = b5 & b1 = Sub_P b4,b5,b6 ) );

definition
let c1 be Element of QC-Sub-WFF ;
assume E28: c1 is Sub_negative ;
func Sub_the_argument_of c1 -> Element of QC-Sub-WFF means :Def30: :: SUBSTUT1:def 30
a1 = Sub_not a2;
existence
ex b1 being Element of QC-Sub-WFF st c1 = Sub_not b1
by E28, Def26;
uniqueness
for b1, b2 being Element of QC-Sub-WFF st c1 = Sub_not b1 & c1 = Sub_not b2 holds
b1 = b2
proof end;
end;

:: deftheorem Def30 defines Sub_the_argument_of SUBSTUT1:def 30 :
for b1 being Element of QC-Sub-WFF st b1 is Sub_negative holds
for b2 being Element of QC-Sub-WFF holds
( b2 = Sub_the_argument_of b1 iff b1 = Sub_not b2 );

definition
let c1 be Element of QC-Sub-WFF ;
assume E29: c1 is Sub_conjunctive ;
func Sub_the_left_argument_of c1 -> Element of QC-Sub-WFF means :Def31: :: SUBSTUT1:def 31
ex b1 being Element of QC-Sub-WFF st
( a1 = Sub_& a2,b1 & a2 `2 = b1 `2 );
existence
ex b1, b2 being Element of QC-Sub-WFF st
( c1 = Sub_& b1,b2 & b1 `2 = b2 `2 )
by E29, Def27;
uniqueness
for b1, b2 being Element of QC-Sub-WFF st ex b3 being Element of QC-Sub-WFF st
( c1 = Sub_& b1,b3 & b1 `2 = b3 `2 ) & ex b3 being Element of QC-Sub-WFF st
( c1 = Sub_& b2,b3 & b2 `2 = b3 `2 ) holds
b1 = b2
proof end;
end;

:: deftheorem Def31 defines Sub_the_left_argument_of SUBSTUT1:def 31 :
for b1 being Element of QC-Sub-WFF st b1 is Sub_conjunctive holds
for b2 being Element of QC-Sub-WFF holds
( b2 = Sub_the_left_argument_of b1 iff ex b3 being Element of QC-Sub-WFF st
( b1 = Sub_& b2,b3 & b2 `2 = b3 `2 ) );

definition
let c1 be Element of QC-Sub-WFF ;
assume E30: c1 is Sub_conjunctive ;
func Sub_the_right_argument_of c1 -> Element of QC-Sub-WFF means :Def32: :: SUBSTUT1:def 32
ex b1 being Element of QC-Sub-WFF st
( a1 = Sub_& b1,a2 & b1 `2 = a2 `2 );
existence
ex b1, b2 being Element of QC-Sub-WFF st
( c1 = Sub_& b2,b1 & b2 `2 = b1 `2 )
proof end;
uniqueness
for b1, b2 being Element of QC-Sub-WFF st ex b3 being Element of QC-Sub-WFF st
( c1 = Sub_& b3,b1 & b3 `2 = b1 `2 ) & ex b3 being Element of QC-Sub-WFF st
( c1 = Sub_& b3,b2 & b3 `2 = b2 `2 ) holds
b1 = b2
proof end;
end;

:: deftheorem Def32 defines Sub_the_right_argument_of SUBSTUT1:def 32 :
for b1 being Element of QC-Sub-WFF st b1 is Sub_conjunctive holds
for b2 being Element of QC-Sub-WFF holds
( b2 = Sub_the_right_argument_of b1 iff ex b3 being Element of QC-Sub-WFF st
( b1 = Sub_& b3,b2 & b3 `2 = b2 `2 ) );

definition
let c1 be set ;
assume E31: c1 is Sub_universal ;
func Sub_the_bound_of c1 -> bound_QC-variable means :: SUBSTUT1:def 33
ex b1 being Element of [:QC-Sub-WFF ,bound_QC-variables :]ex b2 being second_Q_comp of b1 st
( a1 = Sub_All b1,b2 & b1 `2 = a2 & b1 is quantifiable );
existence
ex b1 being bound_QC-variableex b2 being Element of [:QC-Sub-WFF ,bound_QC-variables :]ex b3 being second_Q_comp of b2 st
( c1 = Sub_All b2,b3 & b2 `2 = b1 & b2 is quantifiable )
proof end;
uniqueness
for b1, b2 being bound_QC-variable st ex b3 being Element of [:QC-Sub-WFF ,bound_QC-variables :]ex b4 being second_Q_comp of b3 st
( c1 = Sub_All b3,b4 & b3 `2 = b1 & b3 is quantifiable ) & ex b3 being Element of [:QC-Sub-WFF ,bound_QC-variables :]ex b4 being second_Q_comp of b3 st
( c1 = Sub_All b3,b4 & b3 `2 = b2 & b3 is quantifiable ) holds
b1 = b2
proof end;
end;

:: deftheorem Def33 defines Sub_the_bound_of SUBSTUT1:def 33 :
for b1 being set st b1 is Sub_universal holds
for b2 being bound_QC-variable holds
( b2 = Sub_the_bound_of b1 iff ex b3 being Element of [:QC-Sub-WFF ,bound_QC-variables :]ex b4 being second_Q_comp of b3 st
( b1 = Sub_All b3,b4 & b3 `2 = b2 & b3 is quantifiable ) );

definition
let c1 be set ;
assume E31: c1 is Sub_universal ;
func Sub_the_scope_of c1 -> Element of QC-Sub-WFF means :Def34: :: SUBSTUT1:def 34
ex b1 being Element of [:QC-Sub-WFF ,bound_QC-variables :]ex b2 being second_Q_comp of b1 st
( a1 = Sub_All b1,b2 & b1 `1 = a2 & b1 is quantifiable );
existence
ex b1 being Element of QC-Sub-WFF ex b2 being Element of [:QC-Sub-WFF ,bound_QC-variables :]ex b3 being second_Q_comp of b2 st
( c1 = Sub_All b2,b3 & b2 `1 = b1 & b2 is quantifiable )
proof end;
uniqueness
for b1, b2 being Element of QC-Sub-WFF st ex b3 being Element of [:QC-Sub-WFF ,bound_QC-variables :]ex b4 being second_Q_comp of b3 st
( c1 = Sub_All b3,b4 & b3 `1 = b1 & b3 is quantifiable ) & ex b3 being Element of [:QC-Sub-WFF ,bound_QC-variables :]ex b4 being second_Q_comp of b3 st
( c1 = Sub_All b3,b4 & b3 `1 = b2 & b3 is quantifiable ) holds
b1 = b2
proof end;
end;

:: deftheorem Def34 defines Sub_the_scope_of SUBSTUT1:def 34 :
for b1 being set st b1 is Sub_universal holds
for b2 being Element of QC-Sub-WFF holds
( b2 = Sub_the_scope_of b1 iff ex b3 being Element of [:QC-Sub-WFF ,bound_QC-variables :]ex b4 being second_Q_comp of b3 st
( b1 = Sub_All b3,b4 & b3 `1 = b2 & b3 is quantifiable ) );

registration
let c1 be Element of QC-Sub-WFF ;
cluster Sub_not a1 -> Sub_negative ;
coherence
Sub_not c1 is Sub_negative
proof end;
end;

theorem Th13: :: SUBSTUT1:13
for b1, b2 being Element of QC-Sub-WFF st b1 `2 = b2 `2 holds
Sub_& b1,b2 is Sub_conjunctive
proof end;

theorem Th14: :: SUBSTUT1:14
for b1 being Element of [:QC-Sub-WFF ,bound_QC-variables :]
for b2 being second_Q_comp of b1 st b1 is quantifiable holds
Sub_All b1,b2 is Sub_universal
proof end;

theorem Th15: :: SUBSTUT1:15
for b1, b2 being Element of QC-Sub-WFF st Sub_not b1 = Sub_not b2 holds
b1 = b2
proof end;

theorem Th16: :: SUBSTUT1:16
for b1 being Element of QC-Sub-WFF holds Sub_the_argument_of (Sub_not b1) = b1 by Def30;

theorem Th17: :: SUBSTUT1:17
for b1, b2, b3, b4 being Element of QC-Sub-WFF st b1 `2 = b2 `2 & b3 `2 = b4 `2 & Sub_& b1,b2 = Sub_& b3,b4 holds
( b1 = b3 & b2 = b4 )
proof end;

theorem Th18: :: SUBSTUT1:18
for b1, b2 being Element of QC-Sub-WFF st b1 `2 = b2 `2 holds
Sub_the_left_argument_of (Sub_& b1,b2) = b1
proof end;

theorem Th19: :: SUBSTUT1:19
for b1, b2 being Element of QC-Sub-WFF st b1 `2 = b2 `2 holds
Sub_the_right_argument_of (Sub_& b1,b2) = b2
proof end;

theorem Th20: :: SUBSTUT1:20
for b1, b2 being Element of [:QC-Sub-WFF ,bound_QC-variables :]
for b3 being second_Q_comp of b1
for b4 being second_Q_comp of b2 st b1 is quantifiable & b2 is quantifiable & Sub_All b1,b3 = Sub_All b2,b4 holds
b1 = b2
proof end;

theorem Th21: :: SUBSTUT1:21
for b1 being Element of [:QC-Sub-WFF ,bound_QC-variables :]
for b2 being second_Q_comp of b1 st b1 is quantifiable holds
Sub_the_scope_of (Sub_All b1,b2) = b1 `1
proof end;

scheme :: SUBSTUT1:sch 2
s2{ P1[ Element of QC-Sub-WFF ] } :
for b1 being Element of QC-Sub-WFF holds P1[b1]
provided
E39: for b1 being Element of QC-Sub-WFF holds
( ( b1 is Sub_atomic implies P1[b1] ) & ( b1 is Sub_VERUM implies P1[b1] ) & ( b1 is Sub_negative & P1[ Sub_the_argument_of b1] implies P1[b1] ) & ( b1 is Sub_conjunctive & P1[ Sub_the_left_argument_of b1] & P1[ Sub_the_right_argument_of b1] implies P1[b1] ) & ( b1 is Sub_universal & P1[ Sub_the_scope_of b1] implies P1[b1] ) )
proof end;

theorem Th22: :: SUBSTUT1:22
for b1 being Element of QC-Sub-WFF st b1 is Sub_negative holds
len (@ ((Sub_the_argument_of b1) `1 )) < len (@ (b1 `1 ))
proof end;

theorem Th23: :: SUBSTUT1:23
for b1 being Element of QC-Sub-WFF st b1 is Sub_conjunctive holds
( len (@ ((Sub_the_left_argument_of b1) `1 )) < len (@ (b1 `1 )) & len (@ ((Sub_the_right_argument_of b1) `1 )) < len (@ (b1 `1 )) )
proof end;

theorem Th24: :: SUBSTUT1:24
for b1 being Element of QC-Sub-WFF st b1 is Sub_universal holds
len (@ ((Sub_the_scope_of b1) `1 )) < len (@ (b1 `1 ))
proof end;

theorem Th25: :: SUBSTUT1:25
for b1 being Element of QC-Sub-WFF holds
( ( b1 is Sub_VERUM implies ((@ (b1 `1 )) . 1) `1 = 0 ) & ( b1 is Sub_atomic implies ex b2 being Nat st (@ (b1 `1 )) . 1 is QC-pred_symbol of b2 ) & ( b1 is Sub_negative implies ((@ (b1 `1 )) . 1) `1 = 1 ) & ( b1 is Sub_conjunctive implies ((@ (b1 `1 )) . 1) `1 = 2 ) & ( b1 is Sub_universal implies ((@ (b1 `1 )) . 1) `1 = 3 ) )
proof end;

theorem Th26: :: SUBSTUT1:26
for b1 being Element of QC-Sub-WFF st b1 is Sub_atomic holds
( ((@ (b1 `1 )) . 1) `1 <> 0 & ((@ (b1 `1 )) . 1) `1 <> 1 & ((@ (b1 `1 )) . 1) `1 <> 2 & ((@ (b1 `1 )) . 1) `1 <> 3 )
proof end;

theorem Th27: :: SUBSTUT1:27
for b1 being Element of QC-Sub-WFF holds
( not ( b1 is Sub_atomic & b1 is Sub_negative ) & not ( b1 is Sub_atomic & b1 is Sub_conjunctive ) & not ( b1 is Sub_atomic & b1 is Sub_universal ) & not ( b1 is Sub_negative & b1 is Sub_conjunctive ) & not ( b1 is Sub_negative & b1 is Sub_universal ) & not ( b1 is Sub_conjunctive & b1 is Sub_universal ) & not ( b1 is Sub_VERUM & b1 is Sub_atomic ) & not ( b1 is Sub_VERUM & b1 is Sub_negative ) & not ( b1 is Sub_VERUM & b1 is Sub_conjunctive ) & not ( b1 is Sub_VERUM & b1 is Sub_universal ) )
proof end;

scheme :: SUBSTUT1:sch 3
s3{ F1() -> non empty set , F2() -> Element of F1(), F3( Element of QC-Sub-WFF ) -> Element of F1(), F4( Element of F1()) -> Element of F1(), F5( Element of F1(), Element of F1()) -> Element of F1(), F6( Element of QC-Sub-WFF , Element of F1()) -> Element of F1() } :
ex b1 being Function of QC-Sub-WFF ,F1() st
for b2 being Element of QC-Sub-WFF
for b3, b4 being Element of F1() holds
( ( b2 is Sub_VERUM implies b1 . b2 = F2() ) & ( b2 is Sub_atomic implies b1 . b2 = F3(b2) ) & ( b2 is Sub_negative & b3 = b1 . (Sub_the_argument_of b2) implies b1 . b2 = F4(b3) ) & ( b2 is Sub_conjunctive & b3 = b1 . (Sub_the_left_argument_of b2) & b4 = b1 . (Sub_the_right_argument_of b2) implies b1 . b2 = F5(b3,b4) ) & ( b2 is Sub_universal & b3 = b1 . (Sub_the_scope_of b2) implies b1 . b2 = F6(b2,b3) ) )
proof end;

scheme :: SUBSTUT1:sch 4
s4{ F1() -> non empty set , F2() -> Function of QC-Sub-WFF ,F1(), F3() -> Function of QC-Sub-WFF ,F1(), F4() -> Element of F1(), F5( set ) -> Element of F1(), F6( set ) -> Element of F1(), F7( set , set ) -> Element of F1(), F8( set , set ) -> Element of F1() } :
F2() = F3()
provided
E45: for b1 being Element of QC-Sub-WFF
for b2, b3 being Element of F1() holds
( ( b1 is Sub_VERUM implies F2() . b1 = F4() ) & ( b1 is Sub_atomic implies F2() . b1 = F5(b1) ) & ( b1 is Sub_negative & b2 = F2() . (Sub_the_argument_of b1) implies F2() . b1 = F6(b2) ) & ( b1 is Sub_conjunctive & b2 = F2() . (Sub_the_left_argument_of b1) & b3 = F2() . (Sub_the_right_argument_of b1) implies F2() . b1 = F7(b2,b3) ) & ( b1 is Sub_universal & b2 = F2() . (Sub_the_scope_of b1) implies F2() . b1 = F8(b1,b2) ) ) and
E46: for b1 being Element of QC-Sub-WFF
for b2, b3 being Element of F1() holds
( ( b1 is Sub_VERUM implies F3() . b1 = F4() ) & ( b1 is Sub_atomic implies F3() . b1 = F5(b1) ) & ( b1 is Sub_negative & b2 = F3() . (Sub_the_argument_of b1) implies F3() . b1 = F6(b2) ) & ( b1 is Sub_conjunctive & b2 = F3() . (Sub_the_left_argument_of b1) & b3 = F3() . (Sub_the_right_argument_of b1) implies F3() . b1 = F7(b2,b3) ) & ( b1 is Sub_universal & b2 = F3() . (Sub_the_scope_of b1) implies F3() . b1 = F8(b1,b2) ) )
proof end;

definition
let c1 be Element of QC-Sub-WFF ;
func @ c1 -> Element of [:QC-WFF ,vSUB :] equals :: SUBSTUT1:def 35
a1;
coherence
c1 is Element of [:QC-WFF ,vSUB :]
proof end;
end;

:: deftheorem Def35 defines @ SUBSTUT1:def 35 :
for b1 being Element of QC-Sub-WFF holds @ b1 = b1;

definition
let c1 be Element of [:QC-WFF ,vSUB :];
redefine func `1 as c1 `1 -> Element of QC-WFF ;
coherence
c1 `1 is Element of QC-WFF
proof end;
redefine func `2 as c1 `2 -> CQC_Substitution;
coherence
c1 `2 is CQC_Substitution
proof end;
end;

definition
let c1 be Element of [:QC-WFF ,vSUB :];
func S_Bound c1 -> bound_QC-variable equals :: SUBSTUT1:def 36
x. (upVar (RestrictSub (bound_in (a1 `1 )),(a1 `1 ),(a1 `2 )),(the_scope_of (a1 `1 ))) if bound_in (a1 `1 ) in rng (RestrictSub (bound_in (a1 `1 )),(a1 `1 ),(a1 `2 ))
otherwise bound_in (a1 `1 );
coherence
( ( bound_in (c1 `1 ) in rng (RestrictSub (bound_in (c1 `1 )),(c1 `1 ),(c1 `2 )) implies x. (upVar (RestrictSub (bound_in (c1 `1 )),(c1 `1 ),(c1 `2 )),(the_scope_of (c1 `1 ))) is bound_QC-variable ) & ( not bound_in (c1 `1 ) in rng (RestrictSub (bound_in (c1 `1 )),(c1 `1 ),(c1 `2 )) implies bound_in (c1 `1 ) is bound_QC-variable ) )
;
consistency
for b1 being bound_QC-variable holds verum
;
end;

:: deftheorem Def36 defines S_Bound SUBSTUT1:def 36 :
for b1 being Element of [:QC-WFF ,vSUB :] holds
( ( bound_in (b1 `1 ) in rng (RestrictSub (bound_in (b1 `1 )),(b1 `1 ),(b1 `2 )) implies S_Bound b1 = x. (upVar (RestrictSub (bound_in (b1 `1 )),(b1 `1 ),(b1 `2 )),(the_scope_of (b1 `1 ))) ) & ( not bound_in (b1 `1 ) in rng (RestrictSub (bound_in (b1 `1 )),(b1 `1 ),(b1 `2 )) implies S_Bound b1 = bound_in (b1 `1 ) ) );

definition
let c1 be Element of QC-Sub-WFF ;
let c2 be QC-formula;
func Quant c1,c2 -> Element of QC-WFF equals :: SUBSTUT1:def 37
All (S_Bound (@ a1)),a2;
coherence
All (S_Bound (@ c1)),c2 is Element of QC-WFF
;
end;

:: deftheorem Def37 defines Quant SUBSTUT1:def 37 :
for b1 being Element of QC-Sub-WFF
for b2 being QC-formula holds Quant b1,b2 = All (S_Bound (@ b1)),b2;

Lemma45: for b1, b2 being Function of QC-Sub-WFF , QC-WFF st ( for b3 being Element of QC-Sub-WFF holds
( ( b3 is Sub_VERUM implies b1 . b3 = VERUM ) & ( b3 is Sub_atomic implies b1 . b3 = (the_pred_symbol_of (b3 `1 )) ! (CQC_Subst (Sub_the_arguments_of b3),(b3 `2 )) ) & ( b3 is Sub_negative implies b1 . b3 = 'not' (b1 . (Sub_the_argument_of b3)) ) & ( b3 is Sub_conjunctive implies b1 . b3 = (b1 . (Sub_the_left_argument_of b3)) '&' (b1 . (Sub_the_right_argument_of b3)) ) & ( b3 is Sub_universal implies b1 . b3 = Quant b3,(b1 . (Sub_the_scope_of b3)) ) ) ) & ( for b3 being Element of QC-Sub-WFF holds
( ( b3 is Sub_VERUM implies b2 . b3 = VERUM ) & ( b3 is Sub_atomic implies b2 . b3 = (the_pred_symbol_of (b3 `1 )) ! (CQC_Subst (Sub_the_arguments_of b3),(b3 `2 )) ) & ( b3 is Sub_negative implies b2 . b3 = 'not' (b2 . (Sub_the_argument_of b3)) ) & ( b3 is Sub_conjunctive implies b2 . b3 = (b2 . (Sub_the_left_argument_of b3)) '&' (b2 . (Sub_the_right_argument_of b3)) ) & ( b3 is Sub_universal implies b2 . b3 = Quant b3,(b2 . (Sub_the_scope_of b3)) ) ) ) holds
b1 = b2
proof end;

definition
let c1 be Element of QC-Sub-WFF ;
func CQC_Sub c1 -> Element of QC-WFF means :Def38: :: SUBSTUT1:def 38
ex b1 being Function of QC-Sub-WFF , QC-WFF st
( a2 = b1 . a1 & ( for b2 being Element of QC-Sub-WFF holds
( ( b2 is Sub_VERUM implies b1 . b2 = VERUM ) & ( b2 is Sub_atomic implies b1 . b2 = (the_pred_symbol_of (b2 `1 )) ! (CQC_Subst (Sub_the_arguments_of b2),(b2 `2 )) ) & ( b2 is Sub_negative implies b1 . b2 = 'not' (b1 . (Sub_the_argument_of b2)) ) & ( b2 is Sub_conjunctive implies b1 . b2 = (b1 . (Sub_the_left_argument_of b2)) '&' (b1 . (Sub_the_right_argument_of b2)) ) & ( b2 is Sub_universal implies b1 . b2 = Quant b2,(b1 . (Sub_the_scope_of b2)) ) ) ) );
existence
ex b1 being Element of QC-WFF ex b2 being Function of QC-Sub-WFF , QC-WFF st
( b1 = b2 . c1 & ( for b3 being Element of QC-Sub-WFF holds
( ( b3 is Sub_VERUM implies b2 . b3 = VERUM ) & ( b3 is Sub_atomic implies b2 . b3 = (the_pred_symbol_of (b3 `1 )) ! (CQC_Subst (Sub_the_arguments_of b3),(b3 `2 )) ) & ( b3 is Sub_negative implies b2 . b3 = 'not' (b2 . (Sub_the_argument_of b3)) ) & ( b3 is Sub_conjunctive implies b2 . b3 = (b2 . (Sub_the_left_argument_of b3)) '&' (b2 . (Sub_the_right_argument_of b3)) ) & ( b3 is Sub_universal implies b2 . b3 = Quant b3,(b2 . (Sub_the_scope_of b3)) ) ) ) )
proof end;
uniqueness
for b1, b2 being Element of QC-WFF st ex b3 being Function of QC-Sub-WFF , QC-WFF st
( b1 = b3 . c1 & ( for b4 being Element of QC-Sub-WFF holds
( ( b4 is Sub_VERUM implies b3 . b4 = VERUM ) & ( b4 is Sub_atomic implies b3 . b4 = (the_pred_symbol_of (b4 `1 )) ! (CQC_Subst (Sub_the_arguments_of b4),(b4 `2 )) ) & ( b4 is Sub_negative implies b3 . b4 = 'not' (b3 . (Sub_the_argument_of b4)) ) & ( b4 is Sub_conjunctive implies b3 . b4 = (b3 . (Sub_the_left_argument_of b4)) '&' (b3 . (Sub_the_right_argument_of b4)) ) & ( b4 is Sub_universal implies b3 . b4 = Quant b4,(b3 . (Sub_the_scope_of b4)) ) ) ) ) & ex b3 being Function of QC-Sub-WFF , QC-WFF st
( b2 = b3 . c1 & ( for b4 being Element of QC-Sub-WFF holds
( ( b4 is Sub_VERUM implies b3 . b4 = VERUM ) & ( b4 is Sub_atomic implies b3 . b4 = (the_pred_symbol_of (b4 `1 )) ! (CQC_Subst (Sub_the_arguments_of b4),(b4 `2 )) ) & ( b4 is Sub_negative implies b3 . b4 = 'not' (b3 . (Sub_the_argument_of b4)) ) & ( b4 is Sub_conjunctive implies b3 . b4 = (b3 . (Sub_the_left_argument_of b4)) '&' (b3 . (Sub_the_right_argument_of b4)) ) & ( b4 is Sub_universal implies b3 . b4 = Quant b4,(b3 . (Sub_the_scope_of b4)) ) ) ) ) holds
b1 = b2
by Lemma45;
end;

:: deftheorem Def38 defines CQC_Sub SUBSTUT1:def 38 :
for b1 being Element of QC-Sub-WFF
for b2 being Element of QC-WFF holds
( b2 = CQC_Sub b1 iff ex b3 being Function of QC-Sub-WFF , QC-WFF st
( b2 = b3 . b1 & ( for b4 being Element of QC-Sub-WFF holds
( ( b4 is Sub_VERUM implies b3 . b4 = VERUM ) & ( b4 is Sub_atomic implies b3 . b4 = (the_pred_symbol_of (b4 `1 )) ! (CQC_Subst (Sub_the_arguments_of b4),(b4 `2 )) ) & ( b4 is Sub_negative implies b3 . b4 = 'not' (b3 . (Sub_the_argument_of b4)) ) & ( b4 is Sub_conjunctive implies b3 . b4 = (b3 . (Sub_the_left_argument_of b4)) '&' (b3 . (Sub_the_right_argument_of b4)) ) & ( b4 is Sub_universal implies b3 . b4 = Quant b4,(b3 . (Sub_the_scope_of b4)) ) ) ) ) );

theorem Th28: :: SUBSTUT1:28
for b1 being Element of QC-Sub-WFF st b1 is Sub_negative holds
CQC_Sub b1 = 'not' (CQC_Sub (Sub_the_argument_of b1))
proof end;

theorem Th29: :: SUBSTUT1:29
for b1 being Element of QC-Sub-WFF holds CQC_Sub (Sub_not b1) = 'not' (CQC_Sub b1)
proof end;

theorem Th30: :: SUBSTUT1:30
for b1 being Element of QC-Sub-WFF st b1 is Sub_conjunctive holds
CQC_Sub b1 = (CQC_Sub (Sub_the_left_argument_of b1)) '&' (CQC_Sub (Sub_the_right_argument_of b1))
proof end;

theorem Th31: :: SUBSTUT1:31
for b1, b2 being Element of QC-Sub-WFF st b1 `2 = b2 `2 holds
CQC_Sub (Sub_& b1,b2) = (CQC_Sub b1) '&' (CQC_Sub b2)
proof end;

theorem Th32: :: SUBSTUT1:32
for b1 being Element of QC-Sub-WFF st b1 is Sub_universal holds
CQC_Sub b1 = Quant b1,(CQC_Sub (Sub_the_scope_of b1))
proof end;

definition
func CQC-Sub-WFF -> Subset of QC-Sub-WFF equals :: SUBSTUT1:def 39
{ b1 where B is Element of QC-Sub-WFF : b1 `1 is Element of CQC-WFF } ;
coherence
{ b1 where B is Element of QC-Sub-WFF : b1 `1 is Element of CQC-WFF } is Subset of QC-Sub-WFF
proof end;
end;

:: deftheorem Def39 defines CQC-Sub-WFF SUBSTUT1:def 39 :
CQC-Sub-WFF = { b1 where B is Element of QC-Sub-WFF : b1 `1 is Element of CQC-WFF } ;

registration
cluster CQC-Sub-WFF -> non empty ;
coherence
not CQC-Sub-WFF is empty
proof end;
end;

theorem Th33: :: SUBSTUT1:33
for b1 being Element of QC-Sub-WFF st b1 is Sub_VERUM holds
CQC_Sub b1 is Element of CQC-WFF
proof end;

Lemma53: for b1 being Nat
for b2 being QC-pred_symbol of b1
for b3 being CQC-variable_list of b1 holds the_pred_symbol_of (b2 ! b3) = b2
proof end;

theorem Th34: :: SUBSTUT1:34
for b1 being Nat
for b2 being FinSequence holds
( b2 is CQC-variable_list of b1 iff ( b2 is FinSequence of bound_QC-variables & len b2 = b1 ) )
proof end;

theorem Th35: :: SUBSTUT1:35
for b1 being Nat
for b2 being QC-pred_symbol of b1
for b3 being CQC-variable_list of b1
for b4 being Element of vSUB holds CQC_Sub (Sub_P b2,b3,b4) is Element of CQC-WFF
proof end;

theorem Th36: :: SUBSTUT1:36
for b1 being Element of QC-Sub-WFF st CQC_Sub b1 is Element of CQC-WFF holds
CQC_Sub (Sub_not b1) is Element of CQC-WFF
proof end;

theorem Th37: :: SUBSTUT1:37
for b1, b2 being Element of QC-Sub-WFF st b1 `2 = b2 `2 & CQC_Sub b1 is Element of CQC-WFF & CQC_Sub b2 is Element of CQC-WFF holds
CQC_Sub (Sub_& b1,b2) is Element of CQC-WFF
proof end;

theorem Th38: :: SUBSTUT1:38
for b1 being bound_QC-variable
for b2 being Element of QC-Sub-WFF
for b3 being second_Q_comp of [b2,b1] st CQC_Sub b2 is Element of CQC-WFF & [b2,b1] is quantifiable holds
CQC_Sub (Sub_All [b2,b1],b3) is Element of CQC-WFF
proof end;

scheme :: SUBSTUT1:sch 5
s5{ P1[ set ] } :
for b1 being Element of CQC-Sub-WFF holds P1[b1]
provided
E59: for b1, b2 being Element of CQC-Sub-WFF
for b3 being bound_QC-variable
for b4 being second_Q_comp of [b1,b3]
for b5 being Nat
for b6 being CQC-variable_list of b5
for b7 being QC-pred_symbol of b5
for b8 being Element of vSUB holds
( P1[ Sub_P b7,b6,b8] & ( b1 is Sub_VERUM implies P1[b1] ) & ( P1[b1] implies P1[ Sub_not b1] ) & ( b1 `2 = b2 `2 & P1[b1] & P1[b2] implies P1[ Sub_& b1,b2] ) & ( [b1,b3] is quantifiable & P1[b1] implies P1[ Sub_All [b1,b3],b4] ) )
proof end;

definition
let c1 be Element of CQC-Sub-WFF ;
redefine func CQC_Sub as CQC_Sub c1 -> Element of CQC-WFF ;
coherence
CQC_Sub c1 is Element of CQC-WFF
proof end;
end;