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 Th41:
  for S be locally_directed regular monotone OrderSortedSign, X
be non-empty ManySortedSet of S, t,t1 being Element of TS DTConOSA(X) st t1 in
  OSClass(PTCongruence(X),t) holds (PTMin X).t1 = (PTMin X).t
proof
  let S be locally_directed regular monotone OrderSortedSign, X be non-empty
  ManySortedSet of S, t be Element of TS DTConOSA(X);
  set PTA = ParsedTermsOSA(X), D = DTConOSA(X), R = PTCongruence(X), SPTA = (
  the Sorts of PTA), M = PTMin(X), F = PTClasses(X);
  defpred P3[Element of TS D] means (for t1 being Element of TS DTConOSA(X) st
  t1 in OSClass(R,$1) holds (PTMin X).t1 = (PTMin X).$1 );
  defpred P[DecoratedTree of the carrier of D] means ex t1 being Element of TS
  D st t1 = $1 & P3[t1];
A1: for nt being Symbol of D, ts1 being FinSequence of TS(D) st nt ==> roots
ts1 & (for dt1 being DecoratedTree of the carrier of D st dt1 in rng ts1 holds
  P[dt1]) holds P[nt-tree ts1]
  proof
    let nt being Symbol of D, ts1 being FinSequence of TS(D) such that
A2: nt ==> roots ts1 and
A3: for dt1 being DecoratedTree of the carrier of D st dt1 in rng ts1
    ex t2 being Element of TS D st t2 = dt1 & P3[t2];
    reconsider t1 = nt-tree ts1 as Element of TS D by A2,Th12;
A4: F.t1 = @(nt,F*ts1) by A2,Def21
      .= {[Den(o2,ParsedTermsOSA(X)).x2,s3] where o2 is OperSymbol of S, x2
is Element of Args(o2,ParsedTermsOSA(X)), s3 is Element of S : ( ex o1 being
OperSymbol of S st nt = [o1,the carrier of S] & o1 ~= o2 & len the_arity_of o1
= len the_arity_of o2 & the_result_sort_of o1 <= s3 & the_result_sort_of o2 <=
s3 ) & ex w3 being Element of (the carrier of S)* st dom w3 = dom (F*ts1) & for
    y being Nat st y in dom (F*ts1) holds [x2.y,w3/.y] in (F*ts1).y};
    consider o being OperSymbol of S such that
A5: nt = [o,the carrier of S] and
A6: ts1 in Args(o,PTA) and
    nt-tree ts1 = Den(o,PTA).ts1 and
    for s1 being Element of S holds nt-tree ts1 in SPTA.s1 iff
    the_result_sort_of o <= s1 by A2,Th12;
A7: t1 = OSSym(o,X)-tree ts1 by A5;
    then
A8: LeastSorts (M*ts1) <= the_arity_of o by A2,A5,Th40;
    set Ms = (PTMin X)*ts1, w = the_arity_of o;
A9: dom ts1 = dom w by A6,MSUALG_3:6;
    reconsider ta1 = t1 as Element of SPTA.(LeastSort t1) by Def12;
    take t1;
    thus t1 = nt-tree ts1;
A10: dom (F*ts1) = dom ts1 by FINSEQ_3:120;
A11: OSClass(R,t1) = OSClass(R,ta1) by Def27
      .= proj1(F.t1) by Th25;
A12: rng ts1 c= TS D by FINSEQ_1:def 4;
A13: dom ((PTMin X)*ts1) = dom ts1 by FINSEQ_3:120;
A14: M.t1 = OSSym(LBound(o,LeastSorts (M*ts1)),X)-tree (M*ts1) by A2,A5,A7,Th40
;
    thus for t3 being Element of TS DTConOSA(X) st t3 in OSClass(R,t1) holds (
    PTMin X).t3 = (PTMin X).t1
    proof
      let t3 be Element of TS D;
      assume t3 in OSClass(R,t1);
      then consider s4 being object such that
A15:  [t3,s4] in F.t1 by A11,XTUPLE_0:def 12;
      consider o2 being OperSymbol of S, x2 being Element of Args(o2,
      ParsedTermsOSA(X)), s3 being Element of S such that
A16:  [t3,s4] = [Den(o2,ParsedTermsOSA(X)).x2,s3] and
A17:  ex o1 being OperSymbol of S st nt = [o1,the carrier of S] & o1
~= o2 & len the_arity_of o1 = len the_arity_of o2 & the_result_sort_of o1 <= s3
      & the_result_sort_of o2 <= s3 and
A18:  ex w3 being Element of (the carrier of S)* st dom w3 = dom (F*
ts1) & for y being Nat st y in dom (F*ts1) holds [x2.y,w3/.y] in (F*ts1).y by
A4,A15;
      consider o1 being OperSymbol of S such that
A19:  nt = [o1,the carrier of S] and
A20:  o1 ~= o2 and
A21:  len the_arity_of o1 = len the_arity_of o2 and
      the_result_sort_of o1 <= s3 and
      the_result_sort_of o2 <= s3 by A17;
A22:  o1 = o by A5,A19,XTUPLE_0:1;
      then
A23:  dom w = dom the_arity_of o2 by A21,FINSEQ_3:29;
      reconsider ts3 = x2 as FinSequence of TS(D) by Th13;
A24:  dom ts3 = dom the_arity_of o2 by MSUALG_3:6;
A25:  dom (M*ts3) = dom ts3 by FINSEQ_3:120;
A26:  rng ts3 c= TS D by FINSEQ_1:def 4;
      for k being Nat st k in dom (M*ts3) holds (M*ts3).k = Ms.k
      proof
        consider w3 being Element of (the carrier of S)* such that
        dom w3 = dom (F*ts1) and
A27:    for y being Nat st y in dom (F*ts1) holds [x2.y,w3/.y] in (F*
        ts1).y by A18;
        let k being Nat such that
A28:    k in dom (M*ts3);
A29:    ts3.k in rng ts3 by A25,A28,FUNCT_1:3;
        ts1.k in rng ts1 by A9,A23,A24,A25,A28,FUNCT_1:3;
        then reconsider
        tk1 = ts1.k, tk3 = ts3.k as Element of TS D by A12,A26,A29;
        reconsider tak = tk1 as Element of SPTA.(LeastSort tk1) by Def12;
        consider tk2 be Element of TS D such that
A30:    tk2 = tk1 and
A31:    for t4 being Element of TS D st t4 in OSClass(R,tk2) holds M
        .t4 = M.tk2 by A3,A9,A23,A24,A25,A28,FUNCT_1:3;
        [tk3,w3/.k] in (F*ts1).k by A10,A9,A23,A24,A25,A28,A27;
        then
A32:    [tk3,w3/.k] in F.tk1 by A10,A9,A23,A24,A25,A28,FINSEQ_3:120;
        OSClass(R,tk1) = OSClass(R,tak) by Def27
          .= proj1(F.tk1) by Th25;
        then tk3 in OSClass(R,tk1) by A32,XTUPLE_0:def 12;
        then M.tk3 = M.tk1 by A30,A31;
        then M.tk3 = Ms.k by A13,A9,A23,A24,A25,A28,FINSEQ_3:120;
        hence thesis by A28,FINSEQ_3:120;
      end;
      then
A33:  M*ts3 = M*ts1 by A13,A9,A23,A25,FINSEQ_1:13,MSUALG_3:6;
A34:  OSSym(o2,X) ==> roots x2 by Th13;
      then ex o3 being OperSymbol of S st OSSym(o2,X) = [o3,the carrier of S]
& ts3 in Args(o3,PTA) & OSSym(o2,X)-tree ts3 = Den(o3,PTA).ts3 & for s1 being
Element of S holds OSSym(o2,X)-tree ts3 in SPTA.s1 iff the_result_sort_of o3 <=
      s1 by Th12;
      then consider o3 being OperSymbol of S such that
A35:  OSSym(o2,X) = [o3,the carrier of S] and
      ts3 in Args(o3,PTA) and
A36:  OSSym(o2,X)-tree ts3 = Den(o3,PTA).ts3;
      o2 = o3 by A35,XTUPLE_0:1;
      then
A37:  t3 = OSSym(o2,X)-tree ts3 by A16,A36,XTUPLE_0:1;
      then
A38:  LeastSorts (M*ts3) <= the_arity_of o2 by A34,Th40;
      M.t3 = OSSym(LBound(o2,LeastSorts (M*ts3)),X)-tree (M*ts3) by A34,A37
,Th40;
      hence thesis by A14,A8,A20,A22,A33,A38,OSALG_1:34;
    end;
  end;
A39: for s being Symbol of D st s in Terminals D holds P[root-tree s]
  proof
    let sy be Symbol of D such that
A40: sy in Terminals D;
    reconsider t1 = root-tree sy as Element of TS DTConOSA(X) by A40,
DTCONSTR:def 1;
    take t1;
    thus t1 = root-tree sy;
A41: ex s be Element of S, x be set st x in X.s & sy = [x,s] by A40,Th4;
    let t2 be Element of TS DTConOSA(X);
    assume t2 in OSClass(R,t1);
    hence thesis by A41,Th33;
  end;
  for dt being DecoratedTree of the carrier of D st dt in TS(D) holds P[
  dt] from DTCONSTR:sch 7(A39,A1);
  then ex t1 being Element of TS D st t1 = t & P3[t1];
  hence thesis;
end;
