reserve S for OrderSortedSign;
reserve S for OrderSortedSign,
  X for ManySortedSet of S,
  o for OperSymbol of S ,
  b for Element of ([:the carrier' of S,{the carrier of S}:] \/ Union (coprod X
  ))*;
reserve x for set;

theorem Th8:
  for S be OrderSortedSign, X be non-empty ManySortedSet of S holds
  union rng (ParsedTerms X) = TS (DTConOSA(X))
proof
  let S be OrderSortedSign, X be non-empty ManySortedSet of S;
  set D = DTConOSA(X);
A1: dom (ParsedTerms X) = the carrier of S by PARTFUN1:def 2;
  thus union rng (ParsedTerms X) c= TS D
  proof
    let x be object;
    assume x in union rng (ParsedTerms X);
    then consider A be set such that
A2: x in A and
A3: A in rng (ParsedTerms X) by TARSKI:def 4;
    consider s be object such that
A4: s in dom (ParsedTerms X) and
A5: (ParsedTerms X).s = A by A3,FUNCT_1:def 3;
    reconsider s as Element of S by A4;
    A = ParsedTerms(X,s) by A5,Def8
      .= {a where a is Element of TS(D):
  (ex s1 being Element of S, x be object
st s1 <= s & x in X.s1 & a = root-tree [x,s1]) or ex o1 be OperSymbol of S st [
    o1,the carrier of S] = a.{} & the_result_sort_of o1 <= s};
    then
    ex a be Element of TS(D) st a = x &(
  (ex s1 being Element of S, x be object
   st s1 <= s & x in X.s1 & a = root-tree [x,s1]) or ex o1 be OperSymbol of S
    st [o1,the carrier of S]=a.{} & the_result_sort_of o1 <= s) by A2;
    hence thesis;
  end;
  let x be object;
A6: the carrier of D = (Terminals D) \/ (NonTerminals D) by LANG1:1;
  assume x in TS D;
  then reconsider t = x as Element of TS(D);
A7: rng t c= the carrier of D by RELAT_1:def 19;
A8: NonTerminals D = [:the carrier' of S,{the carrier of S}:] by Th3;
A9: Terminals D = Union (coprod X) by Th3;
  {} in dom t by TREES_1:22;
  then
A10: t.{} in rng t by FUNCT_1:def 3;
  per cases by A7,A10,A6,XBOOLE_0:def 3;
  suppose
A11: t.{} in Terminals D;
    then reconsider a = t.{} as Terminal of D;
    a in union rng(coprod X) by A9,A11,CARD_3:def 4;
    then consider A be set such that
A12: a in A and
A13: A in rng(coprod X) by TARSKI:def 4;
    consider s be object such that
A14: s in dom coprod X and
A15: (coprod X).s = A by A13,FUNCT_1:def 3;
    reconsider s as Element of S by A14;
    A = coprod(s,X) by A15,MSAFREE:def 3;
    then
A16: ex b be set st b in X.s & a = [b,s] by A12,MSAFREE:def 2;
    t = root-tree a by DTCONSTR:9;
    then t in ParsedTerms(X,s) by A16;
    then
A17: t in (ParsedTerms X).s by Def8;
    (ParsedTerms X).s in rng (ParsedTerms X) by A1,FUNCT_1:def 3;
    hence thesis by A17,TARSKI:def 4;
  end;
  suppose
    t.{} in NonTerminals D;
    then reconsider a = t.{} as NonTerminal of D;
    consider o being Element of the carrier' of S, x2 being Element of {the
    carrier of S} such that
A18: a = [o,x2] by A8,DOMAIN_1:1;
    set rs = the_result_sort_of o;
    x2 = the carrier of S by TARSKI:def 1;
    then t in ParsedTerms(X,rs) by A18;
    then
A19: t in (ParsedTerms X).rs by Def8;
    (ParsedTerms X).rs in rng (ParsedTerms X) by A1,FUNCT_1:def 3;
    hence thesis by A19,TARSKI:def 4;
  end;
end;
