:: SUBSTUT2 semantic presentation

theorem Th1: :: SUBSTUT2:1
for b1 being CQC_Substitution ex b2 being Element of CQC-Sub-WFF st
( b2 `1 = VERUM & b2 `2 = b1 )
proof end;

Lemma2: for b1 being Nat
for b2 being QC-pred_symbol of b1
for b3, b4 being Nat st b2 is QC-pred_symbol of b3 & b2 is QC-pred_symbol of b4 holds
b3 = b4
proof end;

theorem Th2: :: SUBSTUT2:2
for b1 being Nat
for b2 being QC-pred_symbol of b1
for b3 being CQC-variable_list of b1
for b4 being CQC_Substitution ex b5 being Element of CQC-Sub-WFF st
( b5 `1 = b2 ! b3 & b5 `2 = b4 )
proof end;

theorem Th3: :: SUBSTUT2:3
for b1 being Nat
for b2 being QC-pred_symbol of b1
for b3, b4 being Nat st b2 is QC-pred_symbol of b3 & b2 is QC-pred_symbol of b4 holds
b3 = b4 by Lemma2;

theorem Th4: :: SUBSTUT2:4
for b1 being Element of CQC-WFF st ( for b2 being CQC_Substitution ex b3 being Element of CQC-Sub-WFF st
( b3 `1 = b1 & b3 `2 = b2 ) ) holds
for b2 being CQC_Substitution ex b3 being Element of CQC-Sub-WFF st
( b3 `1 = 'not' b1 & b3 `2 = b2 )
proof end;

theorem Th5: :: SUBSTUT2:5
for b1, b2 being Element of CQC-WFF st ( for b3 being CQC_Substitution ex b4 being Element of CQC-Sub-WFF st
( b4 `1 = b1 & b4 `2 = b3 ) ) & ( for b3 being CQC_Substitution ex b4 being Element of CQC-Sub-WFF st
( b4 `1 = b2 & b4 `2 = b3 ) ) holds
for b3 being CQC_Substitution ex b4 being Element of CQC-Sub-WFF st
( b4 `1 = b1 '&' b2 & b4 `2 = b3 )
proof end;

definition
let c1 be Element of CQC-WFF ;
let c2 be CQC_Substitution;
redefine func [ as [c1,c2] -> Element of [:QC-WFF ,vSUB :];
coherence
[c1,c2] is Element of [:QC-WFF ,vSUB :]
by ZFMISC_1:def 2;
end;

theorem Th6: :: SUBSTUT2:6
for b1 being Element of CQC-WFF
for b2 being bound_QC-variable
for b3 being CQC_Substitution holds dom (RestrictSub b2,(All b2,b1),b3) misses {b2}
proof end;

theorem Th7: :: SUBSTUT2:7
for b1 being Element of CQC-WFF
for b2 being bound_QC-variable
for b3 being CQC_Substitution st b2 in rng (RestrictSub b2,(All b2,b1),b3) holds
S_Bound [(All b2,b1),b3] = x. (upVar (RestrictSub b2,(All b2,b1),b3),b1)
proof end;

theorem Th8: :: SUBSTUT2:8
for b1 being Element of CQC-WFF
for b2 being bound_QC-variable
for b3 being CQC_Substitution st not b2 in rng (RestrictSub b2,(All b2,b1),b3) holds
S_Bound [(All b2,b1),b3] = b2
proof end;

theorem Th9: :: SUBSTUT2:9
for b1 being Element of CQC-WFF
for b2 being bound_QC-variable
for b3 being CQC_Substitution holds ExpandSub b2,b1,(RestrictSub b2,(All b2,b1),b3) = (@ (RestrictSub b2,(All b2,b1),b3)) +* (b2 | (S_Bound [(All b2,b1),b3]))
proof end;

theorem Th10: :: SUBSTUT2:10
for b1 being Element of CQC-WFF
for b2 being bound_QC-variable
for b3 being CQC_Substitution
for b4 being Element of CQC-Sub-WFF st b4 `2 = (@ (RestrictSub b2,(All b2,b1),b3)) +* (b2 | (S_Bound [(All b2,b1),b3])) & b4 `1 = b1 holds
( [b4,b2] is quantifiable & ex b5 being Element of CQC-Sub-WFF st b5 = [(All b2,b1),b3] )
proof end;

theorem Th11: :: SUBSTUT2:11
for b1 being Element of CQC-WFF
for b2 being bound_QC-variable st ( for b3 being CQC_Substitution ex b4 being Element of CQC-Sub-WFF st
( b4 `1 = b1 & b4 `2 = b3 ) ) holds
for b3 being CQC_Substitution ex b4 being Element of CQC-Sub-WFF st
( b4 `1 = All b2,b1 & b4 `2 = b3 )
proof end;

theorem Th12: :: SUBSTUT2:12
for b1 being Element of CQC-WFF
for b2 being CQC_Substitution ex b3 being Element of CQC-Sub-WFF st
( b3 `1 = b1 & b3 `2 = b2 )
proof end;

definition
let c1 be Element of CQC-WFF ;
let c2 be CQC_Substitution;
redefine func [ as [c1,c2] -> Element of CQC-Sub-WFF ;
coherence
[c1,c2] is Element of CQC-Sub-WFF
proof end;
end;

definition
let c1, c2 be bound_QC-variable;
func Sbst c1,c2 -> CQC_Substitution equals :: SUBSTUT2:def 1
a1 .--> a2;
coherence
c1 .--> c2 is CQC_Substitution
proof end;
end;

:: deftheorem Def1 defines Sbst SUBSTUT2:def 1 :
for b1, b2 being bound_QC-variable holds Sbst b1,b2 = b1 .--> b2;

definition
let c1 be Element of CQC-WFF ;
let c2, c3 be bound_QC-variable;
func c1 . c2,c3 -> Element of CQC-WFF equals :: SUBSTUT2:def 2
CQC_Sub [a1,(Sbst a2,a3)];
coherence
CQC_Sub [c1,(Sbst c2,c3)] is Element of CQC-WFF
;
end;

:: deftheorem Def2 defines . SUBSTUT2:def 2 :
for b1 being Element of CQC-WFF
for b2, b3 being bound_QC-variable holds b1 . b2,b3 = CQC_Sub [b1,(Sbst b2,b3)];

scheme :: SUBSTUT2:sch 1
s1{ P1[ set ] } :
for b1 being Element of CQC-WFF holds P1[b1]
provided
E13: for b1 being Element of CQC-WFF st QuantNbr b1 = 0 holds
P1[b1] and
E14: for b1 being Nat st ( for b2 being Element of CQC-WFF st QuantNbr b2 = b1 holds
P1[b2] ) holds
for b2 being Element of CQC-WFF st QuantNbr b2 = b1 + 1 holds
P1[b2]
proof end;

scheme :: SUBSTUT2:sch 2
s2{ P1[ set ] } :
for b1 being Element of CQC-WFF holds P1[b1]
provided
E13: for b1 being Element of CQC-WFF st QuantNbr b1 <= 0 holds
P1[b1] and
E14: for b1 being Nat st ( for b2 being Element of CQC-WFF st QuantNbr b2 <= b1 holds
P1[b2] ) holds
for b2 being Element of CQC-WFF st QuantNbr b2 <= b1 + 1 holds
P1[b2]
proof end;

theorem Th13: :: SUBSTUT2:13
for b1, b2 being bound_QC-variable holds VERUM . b1,b2 = VERUM
proof end;

theorem Th14: :: SUBSTUT2:14
for b1 being Nat
for b2, b3 being bound_QC-variable
for b4 being QC-pred_symbol of b1
for b5 being CQC-variable_list of b1 holds
( (b4 ! b5) . b2,b3 = b4 ! (CQC_Subst b5,(Sbst b2,b3)) & QuantNbr (b4 ! b5) = QuantNbr ((b4 ! b5) . b2,b3) )
proof end;

theorem Th15: :: SUBSTUT2:15
for b1 being Nat
for b2 being QC-pred_symbol of b1
for b3 being CQC-variable_list of b1
for b4 being CQC_Substitution holds QuantNbr (b2 ! b3) = QuantNbr (CQC_Sub [(b2 ! b3),b4])
proof end;

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

theorem Th16: :: SUBSTUT2:16
for b1 being Element of CQC-WFF
for b2 being CQC_Substitution holds [('not' b1),b2] = Sub_not [b1,b2]
proof end;

theorem Th17: :: SUBSTUT2:17
for b1 being Element of CQC-WFF
for b2, b3 being bound_QC-variable holds
( ('not' b1) . b2,b3 = 'not' (b1 . b2,b3) & ( QuantNbr b1 = QuantNbr (b1 . b2,b3) implies QuantNbr ('not' b1) = QuantNbr (('not' b1) . b2,b3) ) )
proof end;

theorem Th18: :: SUBSTUT2:18
for b1 being Element of CQC-WFF st ( for b2 being CQC_Substitution holds QuantNbr b1 = QuantNbr (CQC_Sub [b1,b2]) ) holds
for b2 being CQC_Substitution holds QuantNbr ('not' b1) = QuantNbr (CQC_Sub [('not' b1),b2])
proof end;

theorem Th19: :: SUBSTUT2:19
for b1, b2 being Element of CQC-WFF
for b3 being CQC_Substitution holds [(b1 '&' b2),b3] = CQCSub_& [b1,b3],[b2,b3]
proof end;

theorem Th20: :: SUBSTUT2:20
for b1, b2 being Element of CQC-WFF
for b3, b4 being bound_QC-variable holds
( (b1 '&' b2) . b3,b4 = (b1 . b3,b4) '&' (b2 . b3,b4) & ( QuantNbr b1 = QuantNbr (b1 . b3,b4) & QuantNbr b2 = QuantNbr (b2 . b3,b4) implies QuantNbr (b1 '&' b2) = QuantNbr ((b1 '&' b2) . b3,b4) ) )
proof end;

theorem Th21: :: SUBSTUT2:21
for b1, b2 being Element of CQC-WFF st ( for b3 being CQC_Substitution holds QuantNbr b1 = QuantNbr (CQC_Sub [b1,b3]) ) & ( for b3 being CQC_Substitution holds QuantNbr b2 = QuantNbr (CQC_Sub [b2,b3]) ) holds
for b3 being CQC_Substitution holds QuantNbr (b1 '&' b2) = QuantNbr (CQC_Sub [(b1 '&' b2),b3])
proof end;

definition
func CFQ -> Function of CQC-Sub-WFF , vSUB equals :: SUBSTUT2:def 3
QSub | CQC-Sub-WFF ;
coherence
QSub | CQC-Sub-WFF is Function of CQC-Sub-WFF , vSUB
proof end;
end;

:: deftheorem Def3 defines CFQ SUBSTUT2:def 3 :
CFQ = QSub | CQC-Sub-WFF ;

definition
let c1 be Element of CQC-WFF ;
let c2 be bound_QC-variable;
let c3 be CQC_Substitution;
func QScope c1,c2,c3 -> CQC-WFF-like Element of [:QC-Sub-WFF ,bound_QC-variables :] equals :: SUBSTUT2:def 4
[[a1,(CFQ . [(All a2,a1),a3])],a2];
coherence
[[c1,(CFQ . [(All c2,c1),c3])],c2] is CQC-WFF-like Element of [:QC-Sub-WFF ,bound_QC-variables :]
;
end;

:: deftheorem Def4 defines QScope SUBSTUT2:def 4 :
for b1 being Element of CQC-WFF
for b2 being bound_QC-variable
for b3 being CQC_Substitution holds QScope b1,b2,b3 = [[b1,(CFQ . [(All b2,b1),b3])],b2];

definition
let c1 be Element of CQC-WFF ;
let c2 be bound_QC-variable;
let c3 be CQC_Substitution;
func Qsc c1,c2,c3 -> second_Q_comp of QScope a1,a2,a3 equals :: SUBSTUT2:def 5
a3;
coherence
c3 is second_Q_comp of QScope c1,c2,c3
proof end;
end;

:: deftheorem Def5 defines Qsc SUBSTUT2:def 5 :
for b1 being Element of CQC-WFF
for b2 being bound_QC-variable
for b3 being CQC_Substitution holds Qsc b1,b2,b3 = b3;

theorem Th22: :: SUBSTUT2:22
for b1 being Element of CQC-WFF
for b2 being bound_QC-variable
for b3 being CQC_Substitution holds
( [(All b2,b1),b3] = CQCSub_All (QScope b1,b2,b3),(Qsc b1,b2,b3) & QScope b1,b2,b3 is quantifiable )
proof end;

theorem Th23: :: SUBSTUT2:23
for b1 being Element of CQC-WFF
for b2 being bound_QC-variable st ( for b3 being CQC_Substitution holds QuantNbr b1 = QuantNbr (CQC_Sub [b1,b3]) ) holds
for b3 being CQC_Substitution holds QuantNbr (All b2,b1) = QuantNbr (CQC_Sub [(All b2,b1),b3])
proof end;

theorem Th24: :: SUBSTUT2:24
for b1 being CQC_Substitution holds QuantNbr VERUM = QuantNbr (CQC_Sub [VERUM ,b1])
proof end;

theorem Th25: :: SUBSTUT2:25
for b1 being Element of CQC-WFF
for b2 being CQC_Substitution holds QuantNbr b1 = QuantNbr (CQC_Sub [b1,b2])
proof end;

theorem Th26: :: SUBSTUT2:26
for b1 being Element of CQC-WFF st b1 is atomic holds
ex b2 being Natex b3 being QC-pred_symbol of b2ex b4 being CQC-variable_list of b2 st b1 = b3 ! b4
proof end;

scheme :: SUBSTUT2:sch 3
s3{ P1[ set ] } :
for b1 being Element of CQC-WFF st QuantNbr b1 = 0 holds
P1[b1]
provided
E21: for b1, b2 being Element of CQC-WFF
for b3 being bound_QC-variable
for b4 being Nat
for b5 being CQC-variable_list of b4
for b6 being QC-pred_symbol of b4 holds
( P1[ VERUM ] & P1[b6 ! b5] & ( P1[b1] implies P1[ 'not' b1] ) & ( P1[b1] & P1[b2] implies P1[b1 '&' b2] ) )
proof end;

definition
let c1, c2 be QC-formula;
assume E21: c1 is_subformula_of c2 ;
mode PATH of c1,c2 -> FinSequence means :Def6: :: SUBSTUT2:def 6
( 1 <= len a3 & a3 . 1 = a1 & a3 . (len a3) = a2 & ( for b1 being Nat st 1 <= b1 & b1 < len a3 holds
ex b2, b3 being Element of QC-WFF st
( a3 . b1 = b2 & a3 . (b1 + 1) = b3 & b2 is_immediate_constituent_of b3 ) ) );
existence
ex b1 being FinSequence st
( 1 <= len b1 & b1 . 1 = c1 & b1 . (len b1) = c2 & ( for b2 being Nat st 1 <= b2 & b2 < len b1 holds
ex b3, b4 being Element of QC-WFF st
( b1 . b2 = b3 & b1 . (b2 + 1) = b4 & b3 is_immediate_constituent_of b4 ) ) )
proof end;
end;

:: deftheorem Def6 defines PATH SUBSTUT2:def 6 :
for b1, b2 being QC-formula st b1 is_subformula_of b2 holds
for b3 being FinSequence holds
( b3 is PATH of b1,b2 iff ( 1 <= len b3 & b3 . 1 = b1 & b3 . (len b3) = b2 & ( for b4 being Nat st 1 <= b4 & b4 < len b3 holds
ex b5, b6 being Element of QC-WFF st
( b3 . b4 = b5 & b3 . (b4 + 1) = b6 & b5 is_immediate_constituent_of b6 ) ) ) );

theorem Th27: :: SUBSTUT2:27
for b1 being Nat
for b2, b3 being QC-formula
for b4 being PATH of b2,b3 st b2 is_subformula_of b3 & 1 <= b1 & b1 <= len b4 holds
ex b5 being QC-formula st
( b5 = b4 . b1 & b5 is_subformula_of b3 )
proof end;

theorem Th28: :: SUBSTUT2:28
for b1 being Nat
for b2 being Element of CQC-WFF
for b3 being QC-formula
for b4 being PATH of b3,b2 st b3 is_subformula_of b2 & 1 <= b1 & b1 <= len b4 holds
b4 . b1 is Element of CQC-WFF
proof end;

theorem Th29: :: SUBSTUT2:29
for b1, b2 being Nat
for b3, b4 being Element of CQC-WFF
for b5 being PATH of b3,b4 st QuantNbr b4 <= b1 & b3 is_subformula_of b4 & 1 <= b2 & b2 <= len b5 holds
ex b6 being Element of CQC-WFF st
( b6 = b5 . b2 & QuantNbr b6 <= b1 )
proof end;

theorem Th30: :: SUBSTUT2:30
for b1 being Nat
for b2, b3 being Element of CQC-WFF st QuantNbr b2 = b1 & b3 is_subformula_of b2 holds
QuantNbr b3 <= b1
proof end;

theorem Th31: :: SUBSTUT2:31
for b1 being Nat
for b2 being Element of CQC-WFF st ( for b3 being Element of CQC-WFF st b3 is_subformula_of b2 holds
QuantNbr b3 = b1 ) holds
b1 = 0
proof end;

theorem Th32: :: SUBSTUT2:32
for b1 being Element of CQC-WFF st ( for b2 being Element of CQC-WFF st b2 is_subformula_of b1 holds
for b3 being bound_QC-variable
for b4 being Element of CQC-WFF holds b2 <> All b3,b4 ) holds
QuantNbr b1 = 0
proof end;

theorem Th33: :: SUBSTUT2:33
for b1 being Element of CQC-WFF st ( for b2 being Element of CQC-WFF st b2 is_subformula_of b1 holds
QuantNbr b2 <> 1 ) holds
QuantNbr b1 = 0
proof end;

theorem Th34: :: SUBSTUT2:34
for b1 being Element of CQC-WFF st 1 <= QuantNbr b1 holds
ex b2 being Element of CQC-WFF st
( b2 is_subformula_of b1 & QuantNbr b2 = 1 ) by Th33;