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

theorem
  for A,B being X,S-terms non-empty MSAlgebra over S
  st the MSAlgebra of A = the MSAlgebra of B
  holds (A is all_vars_including implies B is all_vars_including) &
  (A is inheriting_operations implies B is inheriting_operations) &
  (A is free_in_itself implies B is free_in_itself)
  proof
    let A,B be X,S-terms non-empty MSAlgebra over S such that
A1: the MSAlgebra of A = the MSAlgebra of B;
    thus A is all_vars_including implies B is all_vars_including by A1;
    thus A is inheriting_operations implies B is inheriting_operations
    proof assume
A3:   for o being OperSymbol of S, p being FinSequence holds
      (p in Args(o, Free(S,X)) &
      Den(o,Free(S,X)).p in (the Sorts of A).the_result_sort_of o implies
      p in Args(o,A) & Den(o,A).p = Den(o,Free(S,X)).p);
      let o be OperSymbol of S, p be FinSequence;
      Args(o,A) = Args(o,B) & Den(o,A) = Den(o,B) by A1;
      hence p in Args(o, Free(S,X)) &
      Den(o,Free(S,X)).p in (the Sorts of B).the_result_sort_of o implies
      p in Args(o,B) & Den(o,B).p = Den(o,Free(S,X)).p by A1,A3;
    end;
    assume
A4: for f being ManySortedFunction of FreeGen X, the Sorts of A
    for G being ManySortedSubset of the Sorts of A st G = FreeGen X
    ex h being ManySortedFunction of A,A st h is_homomorphism A,A & f = h || G;
    let f be ManySortedFunction of FreeGen X, the Sorts of B;
    let G be ManySortedSubset of the Sorts of B such that
A5: G = FreeGen X;
    reconsider G1 = G as ManySortedSubset of the Sorts of A by A1;
    consider h being ManySortedFunction of A,A such that
A6: h is_homomorphism A,A & f = h||G1 by A1,A4,A5;
    reconsider h2 = h as ManySortedFunction of B,B by A1;
    take h2;
    thus h2 is_homomorphism B,B by A6,A1,Th30;
    thus f = h2 || G by A1,A6;
  end;
