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

theorem Th18:
  for J being non empty non void Signature
  for S being J-extension Signature
  for T being non-empty MSAlgebra over J
  for I being set st I c= (the carrier of S)\the carrier of J
  for X being non-empty ManySortedSet of I
  ex Q being non-empty MSAlgebra over S st
  Q is T-extension & (the Sorts of Q)|I = X
  proof
    let J be non empty non void Signature;
    let S be J-extension Signature;
    let T be non-empty MSAlgebra over J;
    set K = (the carrier of S)\the carrier of J;
    let I be set; assume
A1: I c= K;
    let X be non-empty ManySortedSet of I;
    set Y = (the non-empty ManySortedSet of K)+*X;
    dom Y = (dom the non-empty ManySortedSet of K)\/dom X by FUNCT_4:def 1
    .= K \/ dom X by PARTFUN1:def 2 .= K \/ I by PARTFUN1:def 2
    .= K by A1,XBOOLE_1:12;
    then reconsider Y as non-empty ManySortedSet of K
    by RELAT_1:def 18,PARTFUN1:def 2;
    consider Q being MSAlgebra over S such that
A2: Q is T-extension & (the Sorts of Q)|K = Y by Th17;
    now
      let x be object; assume
      x in the carrier of S;
      then per cases by XBOOLE_0:def 5;
      suppose
A3:     x in the carrier of J;
        then (the Sorts of Q).x = (the Sorts of T).x by A2,Th16;
        hence (the Sorts of Q).x is non empty by A3;
      end;
      suppose
A4:     x in K;
        then (the Sorts of Q).x = Y.x by A2,FUNCT_1:49;
        hence (the Sorts of Q).x is non empty by A4;
      end;
    end;
    then the Sorts of Q is non-empty;
    then reconsider Q as non-empty MSAlgebra over S by MSUALG_1:def 3;
    take Q; thus Q is T-extension by A2;
A5: dom X = I by PARTFUN1:def 2;
    thus (the Sorts of Q)|I = (the Sorts of Q)|K|I by A1,RELAT_1:74
    .= X by A2,A5;
  end;
