reserve G for Graph,
  k, m, n for Nat;
reserve G for non void Graph;

theorem
  for S being non void non empty ManySortedSign, X being non-empty
ManySortedSet of the carrier of S, v being SortSymbol of S holds {t where t is
  Element of (the Sorts of FreeMSA X).v: depth t = 0} = FreeGen(v, X) \/
  Constants(FreeMSA X, v)
proof
  let S be non void non empty ManySortedSign, X be non-empty ManySortedSet of
  the carrier of S, v be SortSymbol of S;
  set SF = the Sorts of FreeMSA X;
  set d0 = {t where t is Element of SF.v: depth t = 0};
A1: d0 c= FreeGen(v, X) \/ Constants(FreeMSA X, v)
  proof
    let x be object;
    assume x in d0;
    then consider t being Element of SF.v such that
A2: x = t and
A3: depth t = 0;
    t in SF.v;
    then t in FreeSort(X, v) by MSAFREE:def 11;
    then consider a being Element of TS(DTConMSA(X)) such that
A4: t = a and
A5: (ex x be set st x in X.v & a = root-tree [x,v]) or ex o be
    OperSymbol of S st [o,the carrier of S] = a.{} & the_result_sort_of o = v;
    consider dt being finite DecoratedTree, ft being finite Tree such that
A6: dt = t and
A7: ft = dom dt & depth t = height ft by MSAFREE2:def 14;
    per cases by A5;
    suppose
      ex x be set st x in X.v & a = root-tree [x,v];
      then t in FreeGen(v,X) by A4,MSAFREE:def 15;
      hence thesis by A2,XBOOLE_0:def 3;
    end;
    suppose
      ex o be OperSymbol of S st [o,the carrier of S] = a.{} &
      the_result_sort_of o = v;
      then consider o be OperSymbol of S such that
A8:   [o,the carrier of S] = a.{} and
A9:   the_result_sort_of o = v;
A10:  (the ResultSort of S).o = v by A9,MSUALG_1:def 2;
      set ars9 = <*>TS DTConMSA X;
      reconsider t9= t as Term of S, X by A4,MSATERM:def 1;
A11:  ex Av being non empty set st Av = SF.v & Constants( FreeMSA X,v) = {
a1 where a1 is Element of Av : ex o be OperSymbol of S st (the Arity of S).o =
{} & (the ResultSort of S).o = v & a1 in rng Den(o, FreeMSA X)} by
MSUALG_2:def 3;
      consider ars being ArgumentSeq of Sym(o,X) such that
A12:  t9 = [o,the carrier of S]-tree ars by A4,A8,MSATERM:10;
      dt = root-tree (dt.{}) by A3,A7,TREES_1:43,TREES_4:5;
      then
A13:  ars = {} by A6,A12,TREES_4:17;
      then 0 = len ars .= len the_arity_of o by MSATERM:22;
      then the_arity_of o = {};
      then
A14:  (the Arity of S).o = {} by MSUALG_1:def 1;
      then dom Den(o, FreeMSA X) = {{}} by Th23;
      then
A15:  {} in dom Den(o, FreeMSA X) by TARSKI:def 1;
      Sym(o, X) ==> roots ars by MSATERM:21;
      then
A16:  DenOp(o, X).ars9 = t by A12,A13,MSAFREE:def 12;
      Den(o, FreeMSA X) = (FreeOper X).o by MSUALG_1:def 6
        .= DenOp(o, X) by MSAFREE:def 13;
      then t in rng Den(o, FreeMSA X) by A16,A15,FUNCT_1:def 3;
      then t in Constants(FreeMSA X, v) by A14,A10,A11;
      hence thesis by A2,XBOOLE_0:def 3;
    end;
  end;
A17: Constants(FreeMSA X, v) c= d0
  proof
    set p = <*>TS(DTConMSA(X));
    let x be object;
    consider Av being non empty set such that
A18: Av =(the Sorts of FreeMSA X).v and
A19: Constants(FreeMSA X,v) = { a where a is Element of Av : ex o be
OperSymbol of S st (the Arity of S).o = {} & (the ResultSort of S).o = v & a in
    rng Den(o,FreeMSA X)} by MSUALG_2:def 3;
    assume x in Constants(FreeMSA X, v);
    then consider a being Element of Av such that
A20: x = a and
A21: ex o be OperSymbol of S st (the Arity of S).o = {} & (the
    ResultSort of S).o = v & a in rng Den(o,FreeMSA X) by A19;
    consider o being OperSymbol of S such that
A22: (the Arity of S).o = {} and
    (the ResultSort of S).o = v and
A23: a in rng Den(o,FreeMSA X) by A21;
A24: dom Den(o, FreeMSA X) = {{}} by A22,Th23;
    ((FreeSort X)# * (the Arity of S)).o = Args(o,FreeMSA X) by MSUALG_1:def 4
      .= dom Den(o,FreeMSA X) by FUNCT_2:def 1;
    then p in ((FreeSort X)# * (the Arity of S)).o by A24,TARSKI:def 1;
    then Sym(o,X) ==> roots p by MSAFREE:10;
    then
A25: DenOp(o,X).p = (Sym(o,X))-tree p by MSAFREE:def 12;
    reconsider a as Element of (the Sorts of FreeMSA X).v by A18;
    consider d being object such that
A26: d in dom Den(o,FreeMSA X) and
A27: a = Den(o,FreeMSA X).d by A23,FUNCT_1:def 3;
    consider dt being finite DecoratedTree, t being finite Tree such that
A28: dt = a & t = dom dt and
A29: depth a = height t by MSAFREE2:def 14;
A30: Den(o, FreeMSA X) = (FreeOper X).o by MSUALG_1:def 6
      .= DenOp(o, X) by MSAFREE:def 13;
    d = {} by A24,A26,TARSKI:def 1;
    then a = root-tree (Sym(o,X)) by A27,A30,A25,TREES_4:20;
    then height t = 0 by A28,TREES_1:42,TREES_4:3;
    hence thesis by A20,A29;
  end;
  FreeGen(v, X) c= d0
  proof
    let x be object;
    assume
A31: x in FreeGen(v, X);
    then reconsider x9 = x as Element of SF.v;
    consider dt being finite DecoratedTree, t being finite Tree such that
A32: dt = x9 & t = dom dt and
A33: depth x9 = height t by MSAFREE2:def 14;
    ex a being set st a in X.v & x = root-tree [a,v] by A31,MSAFREE:def 15;
    then height t = 0 by A32,TREES_1:42,TREES_4:3;
    hence thesis by A33;
  end;
  then FreeGen(v, X) \/ Constants(FreeMSA X, v) c= d0 by A17,XBOOLE_1:8;
  hence thesis by A1,XBOOLE_0:def 10;
end;
