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;
reserve
  A0 for (X,S)-terms non-empty MSAlgebra over S,
  A1 for all_vars_including (X,S)-terms MSAlgebra over S,
  A2 for all_vars_including inheriting_operations (X,S)-terms MSAlgebra over S,
  A for all_vars_including inheriting_operations free_in_itself
  (X,S)-terms MSAlgebra over S;

theorem Th45:
  FreeGen X is GeneratorSet of A2
  proof set A = A2;
    reconsider G = FreeGen X as ManySortedSubset of the Sorts of A by Def7;
    defpred P[set] means
    for s being SortSymbol of S st $1 in (the Sorts of A).s
    holds $1 in (the Sorts of GenMSAlg G).s;
A1: FreeMSA X = Free(S,X) by MSAFREE3:31;
A2: for s being SortSymbol of S, v being Element of X.s holds
    P[root-tree [v,s]]
    proof
      let s be SortSymbol of S;
      let v be Element of X.s;
      reconsider t = root-tree [v,s] as Term of S,X by MSATERM:4;
      let r be SortSymbol of S; assume
A3:   root-tree [v,s] in (the Sorts of A).r;
      the Sorts of A is ManySortedSubset of the Sorts of Free(S,X) by Def6;then
      (the Sorts of A).r c= (the Sorts of Free(S,X)).r by PBOOLE:def 2,def 18;
      then t in (the Sorts of Free(S,X)).r by A3; then
      t in FreeSort(X,r) by A1,MSAFREE:def 11; then
      r = the_sort_of t by MSATERM:def 5 .= s by MSATERM:14; then
      root-tree [v,s] in FreeGen(r,X) by MSAFREE:def 15; then
A4:   root-tree [v,s] in (FreeGen X).r by MSAFREE:def 16;
      FreeGen X is ManySortedSubset of the Sorts of GenMSAlg G
      by MSUALG_2:def 17; then
      (FreeGen X).r c= (the Sorts of GenMSAlg G).r by PBOOLE:def 2,def 18;
      hence thesis by A4;
    end;
A5: for o being OperSymbol of S, p being ArgumentSeq of Sym(o,X) st
    for t being Term of S,X st t in rng p holds P[t]
    holds P[[o,the carrier of S]-tree p]
    proof
      let o be OperSymbol of S;
      let p be ArgumentSeq of Sym(o,X);
      assume A6: for t being Term of S,X st t in rng p holds P[t];
      let r be SortSymbol of S;
      assume [o,the carrier of S]-tree p in (the Sorts of A).r; then
      reconsider t1 = [o,the carrier of S]-tree p as
      Element of (the Sorts of A).r;
      p is SubtreeSeq of Sym(o,X) by MSATERM:def 2; then
      Sym(o,X) ==> roots p & p is FinSequence of TS DTConMSA X
      by DTCONSTR:def 6; then
A7:   t1 = DenOp(o,X).p by MSAFREE:def 12;
      p is Element of Args(o, FreeMSA X) qua non empty set by INSTALG1:1; then
      p in Args(o, FreeMSA X); then
A8:   p in Args(o, Free(S,X)) by MSAFREE3:31; then
      Den(o,Free(S,X)).p in ((the Sorts of Free(S,X))*the ResultSort of S).o &
      dom the ResultSort of S = the carrier' of S
      by FUNCT_2:5,def 1; then
A9:   Den(o,Free(S,X)).p in (the Sorts of Free(S,X)).the_result_sort_of o
      by FUNCT_1:13;
      Den(o,Free(S,X)).p = t1 by A1,A7,MSAFREE:def 13; then
      Den(o,Free(S,X)).p in (the Sorts of A).the_result_sort_of o
      by A9,Th43; then
A10:   p in Args(o,A) & Den(o,A).p = Den(o,Free(S,X)).p by A8,Def8;
A11:   dom the Arity of S = the carrier' of S by FUNCT_2:def 1;
A12:   Args(o, GenMSAlg G) =
      cc((the Sorts of GenMSAlg G)#,(the_arity_of o qua set)) by A11,FUNCT_1:13
      .= product ((the Sorts of GenMSAlg G)*the_arity_of o)
      by FINSEQ_2:def 5;
A13:  Args(o,A) = cc((the Sorts of A)#,the_arity_of o) by A11,FUNCT_1:13
      .= product ((the Sorts of A)*the_arity_of o) by FINSEQ_2:def 5;
A14:   dom ((the Sorts of GenMSAlg G)*the_arity_of o) = dom the_arity_of o
      by PARTFUN1:def 2;
A15:  dom ((the Sorts of A)*the_arity_of o) = dom the_arity_of o
      by PARTFUN1:def 2; then
A16:   dom p = dom the_arity_of o by A10,A13,CARD_3:9;
      now let x be object; assume
A17:     x in dom the_arity_of o; then
A18:     p.x in rng p & p.x in ((the Sorts of A)*the_arity_of o).x
        by A16,FUNCT_1:def 3,CARD_3:9,A10,A15,A13;
        (the_arity_of o).x in rng the_arity_of o & rng the_arity_of o c=
        the carrier of S by A17,FUNCT_1:def 3; then
        reconsider s = (the_arity_of o).x as SortSymbol of S;
        reconsider px = p.x as Element of (the Sorts of A).s
        by A18,A17,FUNCT_1:13;
        px is Term of S,X by Th42; then
        px in (the Sorts of GenMSAlg G).s by A18,A6;
        hence p.x in ((the Sorts of GenMSAlg G)*the_arity_of o).x
        by A17,FUNCT_1:13;
      end; then
      reconsider q = p as Element of Args(o, GenMSAlg G) by A12,A16,A14
,CARD_3:9;
      reconsider B = the Sorts of GenMSAlg G as
      ManySortedSubset of the Sorts of A by MSUALG_2:def 9;
A19:   B is opers_closed & the Charact of GenMSAlg G = Opers(A,B)
      by MSUALG_2:def 9;
A20:   B is_closed_on o by MSUALG_2:def 6,def 9;
      Den(o, GenMSAlg G) = o/.B by A19,MSUALG_2:def 8
      .= (Den(o,A))|((B# * the Arity of S).o) by A20,MSUALG_2:def 7; then
A21:   Den(o, GenMSAlg G).p = Den(o,A).q by FUNCT_1:49;
A22:   Den(o, GenMSAlg G).q = [o,the carrier of S]-tree p
      by A1,A21,A7,A10,MSAFREE:def 13; then
A23:   [o,the carrier of S]-tree p in Result(o, GenMSAlg G) by FUNCT_2:5;
      dom the ResultSort of S = the carrier' of S by FUNCT_2:def 1; then
A24:   Result(o, GenMSAlg G) = (the Sorts of GenMSAlg G).the_result_sort_of o &
      Result(o, A) = (the Sorts of A).the_result_sort_of o by FUNCT_1:13;
      t1 in Result(o, A) & t1 in (the Sorts of A).r by A10,A21,A22,FUNCT_2:5;
      hence [o,the carrier of S]-tree p in (the Sorts of GenMSAlg G).r
      by A23,A24,PROB_2:def 2,XBOOLE_0:3;
    end;
A25: for t being Term of S,X holds P[t] from MSATERM:sch 1(A2,A5);
    G is GeneratorSet of A
    proof
      now
        the Sorts of GenMSAlg G is ManySortedSubset of the Sorts of A
        by MSUALG_2:def 9;
        hence the Sorts of GenMSAlg G c= the Sorts of A by PBOOLE:def 18;
        thus the Sorts of A c= the Sorts of GenMSAlg G
        proof
          let x be object; assume x in the carrier of S; then
          reconsider s = x as SortSymbol of S;
          let y be object; assume
       y in (the Sorts of A).x; then
          reconsider y as Element of (the Sorts of A).s;
          the Sorts of A is ManySortedSubset of the Sorts of Free(S,X)
          by Def6; then
          (the Sorts of A).s c= (the Sorts of Free(S,X)).s
          by PBOOLE:def 2,def 18; then
          y is Element of (the Sorts of Free(S,X)).s; then
          y is Element of FreeMSA X by MSAFREE3:31; then
          y is Term of S,X by MSAFREE3:6;
          hence thesis by A25;
        end;
      end;
      hence the Sorts of GenMSAlg G = the Sorts of A by PBOOLE:146;
    end;
    hence thesis;
  end;
