reserve X,Y for set, x,y,z for object, i,j,n for natural number;

theorem Th27:
  for n being non empty natural number
  for J being non empty non void Signature
  for T being non-empty MSAlgebra over J
  for X being non empty-yielding GeneratorSet of T
  for S being J-extension non empty non void n PC-correct QC-correct
  QCLangSignature over Union X
  for Y being X-tolerating non empty-yielding ManySortedSet of the carrier of S
  for L being non-empty Language of Y,S st L is subst-correct &
  Y is ManySortedSubset of the Sorts of L
  for x,y being Element of Union Y
  for a being SortSymbol of S st x in Y.a & y in Y.a
  for A being Formula of L
  holds (\notA)/(x,y) = \not(A/(x,y)) &
  for B being Formula of L
  holds (A\andB)/(x,y) = (A/(x,y))\and(B/(x,y)) &
  (A\orB)/(x,y) = (A/(x,y))\or(B/(x,y)) &
  (A\impB)/(x,y) = (A/(x,y))\imp(B/(x,y)) &
  (A\iffB)/(x,y) = (A/(x,y))\iff(B/(x,y)) & \true_L/(x,y) = \true_L
  proof
    let n be non empty natural number;
    let J be non empty non void Signature;
    let T be non-empty MSAlgebra over J;
    let X be non empty-yielding GeneratorSet of T;
    let S be J-extension non empty non void n PC-correct QC-correct
    QCLangSignature over Union X;
    let Y be X-tolerating non empty-yielding ManySortedSet of the carrier of S;
    let L be non-empty Language of Y,S such that
A1: L is subst-correct and
A2: Y is ManySortedSubset of the Sorts of L;
    let x,y be Element of Union Y;
    let a be SortSymbol of S such that
A3: x in Y.a & y in Y.a;
    Y c= the Sorts of L by A2,PBOOLE:def 18;
    then Y.a c= (the Sorts of L).a;
    then reconsider t = y as Element of (the Sorts of L).a by A3;
    let A be Formula of L;
    reconsider aa = <*A*> as Element of Args(In((the connectives of S).n,
    the carrier' of S),L) by Th25;
    set f = the formula-sort of S;
B1: now
      let i; assume i in dom the connectives of S;
      then (the connectives of S).i in rng the connectives of S c=
      the carrier' of S by FUNCT_1:def 3;
      then
B7:   In((the connectives of S).i,the carrier' of S)in rng the connectives of S
      by SUBSET_1:def 8;
      let S1 be QCLangSignature over Union Y;
      assume
B5:   S = S1;
      let z be (Element of Union Y), q be Element of {1,2};
      [q,z] in [:{1,2},Union Y:] & the quant-sort of S = {1,2}
      by Def5,ZFMISC_1:87;
      then (the quantifiers of S1).[q,z] in rng the quantifiers of S &
      rng the quantifiers of S misses rng the connectives of S
      by B5,Def5,FUNCT_2:4;
      hence In((the connectives of S).i, the carrier' of S) <>
      (the quantifiers of S1).(q,z) by B7,XBOOLE_0:3;
    end;
A4: len the connectives of S >= n+5 by Def4;
    0 < n <= n+5 by NAT_1:11;
    then 0+1 <= n <= len the connectives of S by A4,NAT_1:13,XXREAL_0:2;
    then
B2: n in dom the connectives of S by FINSEQ_3:25;
    then (the connectives of S).n = In((the connectives of S).n,
    the carrier' of S) &
    (the connectives of S).n is_of_type <*f*>, f
    by SUBSET_1:def 8,Def4,FUNCT_1:102;
    then
A5: aa/(x,t) = <*A/(x,t)*> & the_result_sort_of In((the connectives of S).n,
    the carrier' of S) = the formula-sort of S by A3,Th26;
B3: not (ex S1 being QCLangSignature over Union Y st S = S1 &
    ex z being (Element of Union Y), q being Element of {1,2} st
    In((the connectives of S).n, the carrier' of S) =
    (the quantifiers of S1).(q,z)) by B1,B2;
    thus (\notA)/(x,y) = (\notA)/(x,t) by A3,A2,Th14
    .= \not(A/(x,t)) by A5,A1,A3,B3
    .= \not(A/(x,y)) by A3,A2,Th14;
    let B be Formula of L;
A6: <*A,B*> in Args(In((the connectives of S).(n+1), the carrier' of S),L)
    & ... &
    <*A,B*> in Args(In((the connectives of S).(n+4), the carrier' of S),L)
    by Th25;
A7: (for a being Element of Args(In((the connectives of S).(n+1),
    the carrier' of S),L) st <*A,B*> = a holds a/(x,t) = <*A/(x,t),B/(x,t)*>)
    & ... &
    (for a being Element of Args(In((the connectives of S).(n+4),
    the carrier' of S),L) st <*A,B*> = a holds a/(x,t) = <*A/(x,t),B/(x,t)*>)
    by A3,Th26;
    reconsider a1 = <*A,B*> as Element of Args(In((the connectives of S).(n+1),
    the carrier' of S),L) by A6;
    reconsider a2 = <*A,B*> as Element of Args(In((the connectives of S).(n+2),
    the carrier' of S),L) by A6;
    reconsider a3 = <*A,B*> as Element of Args(In((the connectives of S).(n+3),
    the carrier' of S),L) by A6;
    reconsider a4 = <*A,B*> as Element of Args(In((the connectives of S).(n+4),
    the carrier' of S),L) by A6;
    1 <= n+1 <= n+1+4 by NAT_1:11;
    then 1 <= n+1 <= len the connectives of S by A4,XXREAL_0:2;
    then
B4: n+1 in dom the connectives of S by FINSEQ_3:25;
    then
A8: (the connectives of S).(n+1) = In((the connectives of S).(n+1),
    the carrier' of S) & ((the connectives of S).(n+1) is_of_type <*f,f*>, f
    & ... & (the connectives of S).(n+4) is_of_type <*f,f*>, f)
    by Def4,SUBSET_1:def 8,FUNCT_1:102;
    then In((the connectives of S).(n+1), the carrier' of S)
    is_of_type <*f,f*>, f;
    then
A9: a1/(x,t) = <*A/(x,t),B/(x,t)*> &
    the_result_sort_of In((the connectives of S).(n+1),
    the carrier' of S) = the formula-sort of S by A7;
B3: not (ex S1 being QCLangSignature over Union Y st S = S1 &
    ex z being (Element of Union Y), q being Element of {1,2} st
    In((the connectives of S).(n+1), the carrier' of S) =
    (the quantifiers of S1).(q,z)) by B1,B4;
    thus (A\andB)/(x,y) = (A\andB)/(x,t) by A3,A2,Th14
    .= (A/(x,t))\and(B/(x,t)) by A1,A3,A9,B3
    .= (A/(x,y))\and(B/(x,t)) by A3,A2,Th14
    .= (A/(x,y))\and(B/(x,y)) by A3,A2,Th14;
    1+1 <= n+2 <= n+2+3 by NAT_1:11;
    then 1 <= n+2 <= len the connectives of S by A4,XXREAL_0:2;
    then
B4: n+2 in dom the connectives of S by FINSEQ_3:25;
    then (the connectives of S).(n+2) = In((the connectives of S).(n+2),
    the carrier' of S) & (the connectives of S).(n+2) is_of_type <*f,f*>, f
    by A8,SUBSET_1:def 8,FUNCT_1:102;
    then
A10: a2/(x,t) = <*A/(x,t),B/(x,t)*> &
    the_result_sort_of In((the connectives of S).(n+2),
    the carrier' of S) = the formula-sort of S by A7;
B3: not (ex S1 being QCLangSignature over Union Y st S = S1 &
    ex z being (Element of Union Y), q being Element of {1,2} st
    In((the connectives of S).(n+2), the carrier' of S) =
    (the quantifiers of S1).(q,z)) by B1,B4;
    thus (A\orB)/(x,y) = (A\orB)/(x,t) by A3,A2,Th14
    .= (A/(x,t))\or(B/(x,t)) by A1,A3,A10,B3
    .= (A/(x,y))\or(B/(x,t)) by A3,A2,Th14
    .= (A/(x,y))\or(B/(x,y)) by A3,A2,Th14;
    1 <= n+2+1 <= n+3+2 by NAT_1:11;
    then 1 <= n+3 <= len the connectives of S by A4,XXREAL_0:2;
    then
B4: n+3 in dom the connectives of S by FINSEQ_3:25;
    then (the connectives of S).(n+3) = In((the connectives of S).(n+3),
    the carrier' of S) & (the connectives of S).(n+3) is_of_type <*f,f*>, f
    by A8,SUBSET_1:def 8,FUNCT_1:102;
    then
A11: a3/(x,t) = <*A/(x,t),B/(x,t)*> &
    the_result_sort_of In((the connectives of S).(n+3),
    the carrier' of S) = the formula-sort of S by A7;
B3: not (ex S1 being QCLangSignature over Union Y st S = S1 &
    ex z being (Element of Union Y), q being Element of {1,2} st
    In((the connectives of S).(n+3), the carrier' of S) =
    (the quantifiers of S1).(q,z)) by B1,B4;
    thus (A\impB)/(x,y) = (A\impB)/(x,t) by A3,A2,Th14
    .= (A/(x,t))\imp(B/(x,t)) by A1,A3,A11,B3
    .= (A/(x,y))\imp(B/(x,t)) by A3,A2,Th14
    .= (A/(x,y))\imp(B/(x,y)) by A3,A2,Th14;
    1 <= n+3+1 <= n+4+1 by NAT_1:11;
    then 1 <= n+4 <= len the connectives of S by A4,XXREAL_0:2;
    then
B4: n+4 in dom the connectives of S by FINSEQ_3:25;
    then (the connectives of S).(n+4) = In((the connectives of S).(n+4),
    the carrier' of S) & (the connectives of S).(n+4) is_of_type <*f,f*>, f
    by A8,SUBSET_1:def 8,FUNCT_1:102;
    then
A12: a4/(x,t) = <*A/(x,t),B/(x,t)*> &
    the_result_sort_of In((the connectives of S).(n+4),
    the carrier' of S) = the formula-sort of S by A7;
B3: not (ex S1 being QCLangSignature over Union Y st S = S1 &
    ex z being (Element of Union Y), q being Element of {1,2} st
    In((the connectives of S).(n+4), the carrier' of S) =
    (the quantifiers of S1).(q,z)) by B1,B4;
    thus (A\iffB)/(x,y) = (A\iffB)/(x,t) by A3,A2,Th14
    .= (A/(x,t))\iff(B/(x,t)) by A1,A3,A12,B3
    .= (A/(x,y))\iff(B/(x,t)) by A3,A2,Th14
    .= (A/(x,y))\iff(B/(x,y)) by A3,A2,Th14;
    reconsider ab = {} as Element of Args(In((the connectives of S).(n+5),
    the carrier' of S),L) by Th25;
    1 <= n+4+1 <= n+5 by NAT_1:11;
    then
B4: n+5 in dom the connectives of S by A4,FINSEQ_3:25;
    then (the connectives of S).(n+5) = In((the connectives of S).(n+5),
    the carrier' of S) & (the connectives of S).(n+5) is_of_type {}, f
    by Def4,SUBSET_1:def 8,FUNCT_1:102;
    then
A13: ab/(x,t) = ab & the_result_sort_of In((the connectives of S).(n+5),
    the carrier' of S) = the formula-sort of S by A3,Th26;
B3: not (ex S1 being QCLangSignature over Union Y st S = S1 &
    ex z being (Element of Union Y), q being Element of {1,2} st
    In((the connectives of S).(n+5), the carrier' of S) =
    (the quantifiers of S1).(q,z)) by B1,B4;
    thus \true_L/(x,y) = \true_L/(x,t) by A3,A2,Th14 .= \true_L
    by A1,A3,A13,B3;
  end;
