reserve i for Nat, x,y for set;
reserve S for non empty non void ManySortedSign;
reserve X for non-empty ManySortedSet of S;

theorem Th59:
  for n,m being Nat, s,r being set st n >= 1 & m >= 1
  for B being m-connectives non empty non void BoolSignature
  for A1 being non-empty MSAlgebra over B
  for C being non empty non void ConnectivesSignature
  st C is (n,s,r)-array
  for A2 being non-empty MSAlgebra over C
  st the Sorts of A1 tolerates the Sorts of A2 & A2 is (n,s,r)-array
  for S being non empty non void BoolSignature
  st the BoolSignature of S = B+*C
  for A being non-empty MSAlgebra over S
  st A = (B,A1)+*A2 holds A is (m+n,s,r)-array
  proof
    let n,m be Nat;
    let s,r be set;
    assume A1: n >= 1 & m >= 1;
    let B be m-connectives non empty non void BoolSignature;
    let A1 be non-empty MSAlgebra over B;
    let C be non empty non void ConnectivesSignature;
    assume A2: C is (n,s,r)-array;
    then
A3: len the connectives of C >= n+3 &
    ex J,K,L being Element of C st L = s & K = r & J <> L & J <> K &
    (the connectives of C).n is_of_type <*J,K*>, L &
    (the connectives of C).(n+1) is_of_type <*J,K,L*>, J &
    (the connectives of C).(n+2) is_of_type <*J*>, K &
    (the connectives of C).(n+3) is_of_type <*K,L*>, J;
    let A2 be non-empty MSAlgebra over C;
    assume A4: the Sorts of A1 tolerates the Sorts of A2;
    given J,K being Element of C such that
A5: K = s &
    (the connectives of C).n is_of_type <*J,r*>, K &
    (the Sorts of A2).J = ((the Sorts of A2).K)^omega &
    (the Sorts of A2).r = INT &
    (for a being 0 -based finite array of (the Sorts of A2).K holds
    (for i being Integer st i in dom a holds
    Den((the connectives of C)/.n,A2).<*a,i*> = a.i &
    for x being Element of A2,K holds
    Den((the connectives of C)/.(n+1),A2).<*a,i,x*> = a+*(i,x)) &
    Den((the connectives of C)/.(n+2),A2).<*a*> = card a) &
    for i being Integer, x being Element of A2,K st i >= 0
    holds Den((the connectives of C)/.(n+3),A2).<*i,x*> = Segm(i)-->x;
    let S be non empty non void BoolSignature;
    assume A6: the BoolSignature of S = B+*C;
    set k = K;
    the carrier of S = (the carrier of B)\/the carrier of C by A6,Th51;
    then reconsider J,K as Element of S by XBOOLE_0:def 3;
    reconsider k0 = K as Element of B+*C by A6;
    let A be non-empty MSAlgebra over S;
    assume A7: A = (B,A1)+*A2;
    take J,K; thus K = s by A5;
A8: len the connectives of B = m by Def29;
A9: the connectives of S = (the connectives of B)^the connectives of C
    by A6,Def52;
A10: dom the Sorts of A2 = the carrier of C by PARTFUN1:def 2;
A11: r in dom the Sorts of A2 by A5,FUNCT_1:def 2;
    reconsider R = r as Element of C by A10,A5,FUNCT_1:def 2;
A12: the Arity of S = (the Arity of B)+*the Arity of C by A6,Th51;
    n > 0 by A1;
    then
A13: B+*C is (m+n,s,r)-array by A2,Th53;
    then
A14: len the connectives of B+*C >= m+n+3;
    consider J0,K0,L0 being Element of B+*C such that
A15: L0 = s & K0 = r & J0 <> L0 & J0 <> K0 &
    (the connectives of B+*C).(m+n) is_of_type <*J0,K0*>, L0 &
    (the connectives of B+*C).(m+n+1) is_of_type <*J0,K0,L0*>, J0 and
    (the connectives of B+*C).(m+n+2) is_of_type <*J0*>, K0 &
    (the connectives of B+*C).(m+n+3) is_of_type <*K0,L0*>, J0 by A13;
A16: the Sorts of A = (the Sorts of A1)+*the Sorts of A2 &
    the Charact of A = (the Charact of A1)+*the Charact of A2
    by A4,A7,CIRCCOMB:def 4;
    m+n <= m+n+3 & n <= n+3 by NAT_1:11;
    then 1 <= m+n & m+n <= len the connectives of S &
    1 <= n & n <= len the connectives of C
    by A1,A6,A3,A14,NAT_1:12,XXREAL_0:2;
    then
A17: m+n in dom the connectives of S & n in dom the connectives of C &
    dom the Sorts of A2 = the carrier of C &
    dom the Arity of C = the carrier' of C
    by PARTFUN1:def 2,FINSEQ_3:25;
    then
A18: (the connectives of S)/.(m+n) = (the connectives of S).(m+n) &
    (the connectives of C)/.n = (the connectives of C).n &
    (the connectives of C).n = (the connectives of S).(m+n)
    by A9,A8,PARTFUN1:def 6,FINSEQ_1:def 7;
    (the Arity of S).((the connectives of S).(m+n))
    = (the Arity of C).((the connectives of C).n) by A12,A18,A17,FUNCT_4:13;
    then <*J0,r*> = (the Arity of C).((the connectives of C).n) by A6,A15
    .= <*J,r*> by A5;
    then J0 = <*J,r*>.1 .= J;
    then (the connectives of B+*C).(m+n) is_of_type <*J,r*>, k0 &
    the ManySortedSign of S = the ManySortedSign of B+*C by A6,A15,A5;
    hence (the connectives of S).(m+n) is_of_type <*J,r*>, K by A6;
    (the Sorts of A).K = (the Sorts of A2).K &
    (the Sorts of A).r = (the Sorts of A2).r &
    (the Sorts of A).J = (the Sorts of A2).J by A10,A11,A16,FUNCT_4:13;
    hence (the Sorts of A).J = ((the Sorts of A).K)^omega &
    (the Sorts of A).r = INT by A5;
    hereby
      let a be 0 -based finite array of (the Sorts of A).K;
      hereby
        let i be Integer; assume
A19:     i in dom a;
        (the connectives of C).n in the carrier' of C &
        dom the Charact of A2 = the carrier' of C &
        dom the Sorts of A2 = the carrier of C
        by A18,PARTFUN1:def 2;
        then (the Charact of A2).((the connectives of C)/.n)
        = (the Charact of A).((the connectives of S)/.(m+n)) &
        (the Sorts of A2).s = (the Sorts of A).s
        by A5,A16,A18,FUNCT_4:13;
        hence Den((the connectives of S)/.(m+n),A).<*a,i*> = a.i by A19,A5;
        let x be Element of A,K;
        m+n+1 <= m+n+1+2 & n+1 <= n+1+2 by NAT_1:11;
        then 1 <= m+n+1 & m+n+1 <= len the connectives of S &
        1 <= n+1 & n+1 <= len the connectives of C
        by A6,A3,A14,NAT_1:12,XXREAL_0:2;
        then
A20:     m+n+1 in dom the connectives of S & n+1 in dom the connectives of C &
        dom the Sorts of A2 = the carrier of C
        by PARTFUN1:def 2,FINSEQ_3:25;
A21:     (the connectives of S)/.(m+n+1) = (the connectives of S).(m+n+1) &
        (the connectives of C)/.(n+1) = (the connectives of C).(n+1) &
        (the connectives of C).(n+1) = (the connectives of S).(m+(n+1))
        by A9,A8,A20,PARTFUN1:def 6,FINSEQ_1:def 7;
        then (the connectives of C).(n+1) in the carrier' of C &
        dom the Charact of A2 = the carrier' of C & m+(n+1) = m+n+1 &
        dom the Sorts of A2 = the carrier of C
        by PARTFUN1:def 2;
        then (the Charact of A2).((the connectives of C)/.(n+1))
        = (the Charact of A).((the connectives of S)/.(m+n+1)) &
        (the Sorts of A2).k = (the Sorts of A).k0
        by A16,A21,FUNCT_4:13;
        hence Den((the connectives of S)/.(m+n+1),A).<*a,i,x*> = a+*(i,x)
        by A5,A19;
      end;
      m+n+2 <= m+n+2+1 & m+n+3 <= len the connectives of S &
      n+2+1 >= n+2 & n+3 <= len the connectives of C
      by A13,A2,A6,NAT_1:11;
      then 1 <= m+n+2 & m+n+2 <= len the connectives of S &
      1 <= n+2 & n+2 <= len the connectives of C by XXREAL_0:2,NAT_1:12;
      then
A22:   m+n+2 in dom the connectives of S & n+2 in dom the connectives of C &
      dom the Sorts of A2 = the carrier of C
      by PARTFUN1:def 2,FINSEQ_3:25;
A23:   (the connectives of S)/.(m+n+2) = (the connectives of S).(m+n+2) &
      (the connectives of C)/.(n+2) = (the connectives of C).(n+2) &
      (the connectives of C).(n+2) = (the connectives of S).(m+(n+2))
      by A9,A8,A22,PARTFUN1:def 6,FINSEQ_1:def 7;
      then (the connectives of C).(n+2) in the carrier' of C &
      dom the Charact of A2 = the carrier' of C & m+(n+2) = m+n+2 &
      dom the Sorts of A2 = the carrier of C
      by PARTFUN1:def 2;
      then (the Charact of A2).((the connectives of C)/.(n+2))
      = (the Charact of A).((the connectives of S)/.(m+n+2)) &
      (the Sorts of A2).k = (the Sorts of A).k0
      by A16,A23,FUNCT_4:13;
      hence Den((the connectives of S)/.(m+n+2),A).<*a*> = card a by A5;
    end;
    let i be Integer;
    let x be Element of A,K;
    assume A24: i >= 0;
    1 <= m+n+3 & m+n+3 <= len the connectives of S &
    1 <= n+3 & n+3 <= len the connectives of C
    by A2,A6,A13,NAT_1:12;
    then
A25: m+n+3 in dom the connectives of S & n+3 in dom the connectives of C &
    dom the Sorts of A2 = the carrier of C
    by PARTFUN1:def 2,FINSEQ_3:25;
A26: (the connectives of S)/.(m+n+3) = (the connectives of S).(m+n+3) &
    (the connectives of C)/.(n+3) = (the connectives of C).(n+3) &
    (the connectives of C).(n+3) = (the connectives of S).(m+(n+3))
    by A9,A8,A25,PARTFUN1:def 6,FINSEQ_1:def 7;
    then (the connectives of C).(n+3) in the carrier' of C &
    dom the Charact of A2 = the carrier' of C & m+(n+3) = m+n+3 &
    dom the Sorts of A2 = the carrier of C
    by PARTFUN1:def 2;
    then (the Charact of A2).((the connectives of C)/.(n+3))
    = (the Charact of A).((the connectives of S)/.(m+n+3)) &
    (the Sorts of A2).k = (the Sorts of A).k0
    by A16,A26,FUNCT_4:13;
    hence Den((the connectives of S)/.(m+n+3),A).<*i,x*> = Segm(i)-->x 
      by A5,A24;
  end;
