reserve x for set,
  R for non empty Poset;
reserve S1 for OrderSortedSign,
  OU0 for OSAlgebra of S1;
reserve s,s1,s2,s3,s4 for SortSymbol of S1;

theorem Th31:
  for S be non void non empty ManySortedSign for U0 be MSAlgebra
  over S for A be MSSubset of U0 holds GenMSAlg(A) = U0 | MSSubSort(A) & the
  Sorts of GenMSAlg(A) = MSSubSort(A)
proof
  let S be non void non empty ManySortedSign, U0 be MSAlgebra over S, A be
  MSSubset of U0;
  set a = MSSubSort(A);
  reconsider u1 = U0|a as strict MSSubAlgebra of U0;
A1: u1 = MSAlgebra (# a, Opers(U0,a)qua ManySortedFunction of (a# * the
    Arity of S),(a * the ResultSort of S)#) by MSUALG_2:20,def 15;
A2: A c= a by MSUALG_2:20;
A3: A is MSSubset of u1 & for U1 be MSSubAlgebra of U0 st A is MSSubset of
  U1 holds u1 is MSSubAlgebra of U1
  proof
    thus A is MSSubset of u1 by A2,A1,PBOOLE:def 18;
    let U2 be MSSubAlgebra of U0;
    reconsider B = the Sorts of U2 as MSSubset of U0 by MSUALG_2:def 9;
    Constants(U0) is MSSubset of U2 by MSUALG_2:10;
    then
A4: Constants(U0) c= B by PBOOLE:def 18;
    assume A is MSSubset of U2;
    then B is opers_closed & A c= B by MSUALG_2:def 9,PBOOLE:def 18;
    then
A5: B in SubSort(A) by A4,MSUALG_2:13;
    the Sorts of u1 c= the Sorts of U2
    proof
      let i be object;
      assume i in the carrier of S;
      then reconsider s = i as SortSymbol of S;
      (the Sorts of u1).s = meet SubSort(A,s) & B.s in SubSort(A,s) by A1,A5,
MSUALG_2:def 13,def 14;
      hence thesis by SETFAM_1:3;
    end;
    hence thesis by MSUALG_2:8;
  end;
  hence GenMSAlg(A) = U0|a by MSUALG_2:def 17;
  thus thesis by A1,A3,MSUALG_2:def 17;
end;
