reserve
  a,b for object, I,J for set, f for Function, R for Relation,
  i,j,n for Nat, m for (Element of NAT),
  S for non empty non void ManySortedSign,
  s,s1,s2 for SortSymbol of S,
  o for OperSymbol of S,
  X for non-empty ManySortedSet of the carrier of S,
  x,x1,x2 for (Element of X.s), x11 for (Element of X.s1),
  T for all_vars_including inheriting_operations free_in_itself
  (X,S)-terms MSAlgebra over S,
  g for Translation of Free(S,X),s1,s2,
  h for Endomorphism of Free(S,X);
reserve
  r,r1,r2 for (Element of T),
  t,t1,t2 for (Element of Free(S,X));
reserve
  Y for infinite-yielding ManySortedSet of the carrier of S,
  y,y1 for (Element of Y.s), y11 for (Element of Y.s1),
  Q for all_vars_including inheriting_operations free_in_itself
  (Y,S)-terms MSAlgebra over S,
  q,q1 for (Element of Args(o,Free(S,Y))),
  u,u1,u2 for (Element of Q),
  v,v1,v2 for (Element of Free(S,Y)),
  Z for non-trivial ManySortedSet of the carrier of S,
  z,z1 for (Element of Z.s),
  l,l1 for (Element of Free(S,Z)),
  R for all_vars_including inheriting_operations free_in_itself
  (Z,S)-terms MSAlgebra over S,
  k,k1 for Element of Args(o,Free(S,Z));
reserve c,c1,c2 for set, d,d1 for DecoratedTree;
reserve
  w for (Element of Args(o,T)),
  p,p1 for Element of Args(o,Free(S,X));
reserve C for (context of x), C1 for (context of y), C9 for (context of z),
  C11 for (context of x11), C12 for (context of y11), D for context of s,X;
reserve
  S9 for sufficiently_rich non empty non void ManySortedSign,
  s9 for SortSymbol of S9,
  o9 for s9-dependent OperSymbol of S9,
  X9 for non-trivial ManySortedSet of the carrier of S9,
  x9 for (Element of X9.s9);

theorem Th43:
  for w,p being Element of Args(o,Free(S,Z)) for t being Element of Free(S,Z)
  st w is z-context_including & C9 = o-term w &
  p = w+*(z-context_pos_in w, (z-context_in w)-sub(t)) &
  the_sort_of t = s
  holds C9-sub(t) = o-term p
  proof
    let w,p be Element of Args(o,Free(S,Z));
    let t be Element of Free(S,Z);
    assume that
A1: w is z-context_including and
A2: C9 = o-term w and
A3: p = w+*(z-context_pos_in w, (z-context_in w)-sub(t)) and
A4: the_sort_of t = s;
A5: dom p = dom the_arity_of o = dom w <> {} by A1,MSUALG_3:6;
    then reconsider v = w, q = p as non empty DTree-yielding FinSequence;
    now let i,d1; assume
A6:   i in dom v & d1 = v.i;
A7:   (z-context_in w)-sub(t) = (z-context_in w,[z,s])<-t by A4,SUB;
      per cases;
      suppose
A8:     i = z-context_pos_in w;
        then d1 = z-context_in w by A1,A6,Th71;
        hence q.i = (d1,[z,s])<-t by A3,A6,A7,A8,FUNCT_7:31;
      end;
      suppose
A8:     i <> z-context_pos_in w;
        then w/.i is z-omitting & w/.i = d1 by A1,A6,Th72,PARTFUN1:def 6;
        then (d1,[z,s])<-t = d1 by Th23;
        hence q.i = (d1,[z,s])<-t by A3,A6,A8,FUNCT_7:32;
      end;
    end;
    then ([o,the carrier of S]-tree v,[z,s])<-t
    = [o,the carrier of S]-tree q by A5,ThL8;
    hence C9-sub(t) = o-term p by A2,A4,SUB;
  end;
