reserve S,S9 for non void Signature,
  f,g for Function;

theorem
  for S1,S2 being non void Signature st S1 tolerates S2 for f,g being
Function st f,g form_a_replacement_in S1+*S2 holds (S1+*S2) with-replacement (f
  ,g) = (S1 with-replacement (f,g))+*(S2 with-replacement (f,g))
proof
  let S1,S2 be non void Signature such that
A1: S1 tolerates S2;
A2: the ResultSort of S1 tolerates the ResultSort of S2 by A1;
A3: rng the Arity of S2 c= (the carrier of S2)*;
A4: rng the ResultSort of S2 c= the carrier of S2;
A5: rng the ResultSort of S1 c= the carrier of S1;
  set S = S1+*S2;
  let f,g be Function such that
A6: f,g form_a_replacement_in S1+*S2;
  deffunc F(non void Signature) = (the carrier of $1)-indexing f;
  deffunc T(non void Signature) = $1 with-replacement (f,g);
A7: dom F(S2) = the carrier of S2 by PARTFUN1:def 2;
A8: F(S1) tolerates F(S2) by Th19;
A9: S is Extension of S1 by A1,Th47;
  then reconsider
  F1 = F(S1) as Function of the carrier of S1, the carrier of T(S1)
  by A6,Th36,Th52;
A10: dom (F(S1)*(the ResultSort of S1)) = the carrier' of S1 by PARTFUN1:def 2;
  deffunc G(non void Signature) = (the carrier' of $1)-indexing g;
A11: dom F(S1) = the carrier of S1 by PARTFUN1:def 2;
A12: dom G(S1) = the carrier' of S1 by PARTFUN1:def 2;
  set g1 = the rng-retract of G(S1),g2 = the rng-retract of G(S2);
A13: the ResultSort of S = (the ResultSort of S1)+*the ResultSort of S2 by
CIRCCOMB:def 2;
A14: rng g2 c= dom G(S2) by Th23;
A15: the carrier' of S = (the carrier' of S1) \/ the carrier' of S2 by
CIRCCOMB:def 2;
  then G(S) = G(S1) \/ G(S2) by Th20;
  then
A16: rng G(S) = (rng G(S1)) \/ rng G(S2) by RELAT_1:12;
A17: dom G(S2) = the carrier' of S2 by PARTFUN1:def 2;
A18: S is Extension of S2 by Th48;
  then reconsider
  F2 = F(S2) as Function of the carrier of S2, the carrier of T(S2)
  by A6,Th36,Th52;
A19: dom (F(S2)*(the ResultSort of S2)) = the carrier' of S2 by PARTFUN1:def 2;
A20: the carrier of S = (the carrier of S1) \/ the carrier of S2 by
CIRCCOMB:def 2;
  then
A21: F(S) = F(S1)+*F(S2) by Th18;
  F(S) = F(S1) \/ F(S2) by A20,Th20;
  then
A22: rng F(S) = (rng F(S1)) \/ rng F(S2) by RELAT_1:12;
A23: dom (F2**the Arity of S2) = the carrier' of S2 by FUNCT_2:def 1;
A24: dom (F2*) = (the carrier of S2)* by FUNCT_2:def 1;
  G(S) = G(S1)+*G(S2) by A15,Th18;
  then reconsider gg = g1+*g2 as rng-retract of G(S) by Th19,Th27;
A25: rng g1 c= dom G(S1) by Th23;
A26: the ResultSort of T(S) = F(S)*(the ResultSort of S)*gg by A6,Th38
    .= ((F(S1)*the ResultSort of S1)+*(F(S2)*the ResultSort of S2))*gg by A13
,A21,A5,A4,A11,A7,Th19,FUNCT_4:69
    .= (F(S1)*(the ResultSort of S1)*g1)+*(F(S2)*(the ResultSort of S2)*g2)
  by A8,A25,A14,A12,A17,A10,A19,A2,Th4,FUNCT_4:69
    .= (the ResultSort of T(S1))+*(F(S2)*(the ResultSort of S2)*g2) by A6,A9
,Th38,Th52
    .= (the ResultSort of T(S1))+*the ResultSort of T(S2) by A6,A18,Th38,Th52;
A27: the carrier of T(S) = rng F(S) by A6,Def4;
A28: dom (F1**the Arity of S1) = the carrier' of S1 by FUNCT_2:def 1;
  reconsider FS = F(S) as Function of the carrier of S, the carrier of T(S) by
A6,Th36;
A29: (rng the Arity of S) /\ dom (FS*) c= rng the Arity of S by XBOOLE_1:17;
A30: the Arity of S = (the Arity of S1)+*the Arity of S2 by CIRCCOMB:def 2;
A31: f,g form_a_replacement_in S1 by A6,A9,Th52;
  then
A32: the carrier of T(S1) = rng F(S1) by Def4;
A33: the carrier' of T(S1) = rng G(S1) by A31,Def4;
A34: the carrier' of T(S) = rng G(S) by A6,Def4;
A35: dom (F1*) = (the carrier of S1)* by FUNCT_2:def 1;
  the Arity of S1 tolerates the Arity of S2 by A1;
  then the Arity of S = (the Arity of S1) \/ the Arity of S2 by A30,FUNCT_4:30;
  then rng the Arity of S = (rng the Arity of S1) \/ rng the Arity of S2 by
RELAT_1:12;
  then rng the Arity of S c= (the carrier of S1)* \/ (the carrier of S2)* by
XBOOLE_1:13;
  then rng the Arity of S c= dom (F1*+*(F2*)) by A35,A24,FUNCT_4:def 1;
  then
A36: (rng the Arity of S) /\ dom (FS*) c= dom (F1*+*(F2*)) by A29;
A37: f,g form_a_replacement_in S2 by A6,A18,Th52;
  then
A38: the carrier of T(S2) = rng F(S2) by Def4;
A39: the carrier' of T(S2) = rng G(S2) by A37,Def4;
A40: F1* tolerates F2* by Th6,Th19;
A41: F1* +* (F2*) c= F1* \/ F2* by FUNCT_4:29;
  F2 = FS|the carrier of S2 by A20,Th17,XBOOLE_1:7;
  then
A42: F2* c= FS* by Th5,RELAT_1:59;
  F1 = FS|the carrier of S1 by A20,Th17,XBOOLE_1:7;
  then F1* c= FS* by Th5,RELAT_1:59;
  then F1* \/ F2* c= FS* by A42,XBOOLE_1:8;
  then
A43: F1* +* (F2*) c= FS* by A41;
A44: the Arity of S1 tolerates the Arity of S2 by A1;
A45: rng the Arity of S1 c= (the carrier of S1)*;
A46: f,g form_a_replacement_in S1 by A6,A9,Th52;
  the Arity of T(S) = FS**(the Arity of S)*gg by A6,Th37
    .= (F1*+*(F2*))*(the Arity of S)*gg by A43,A36,Th2
    .= ((F1**the Arity of S1)+*(F2**the Arity of S2))*gg by A30,A8,A45,A3,A35
,A24,Th6,FUNCT_4:69
    .= ((F1**the Arity of S1)*g1)+*((F2**the Arity of S2)*g2) by A25,A14,A12
,A17,A40,A44,A28,A23,Th4,FUNCT_4:69
    .= (the Arity of T(S1))+*((F2**the Arity of S2)*g2) by A46,Th37
    .= (the Arity of T(S1))+*the Arity of T(S2) by A6,A18,Th37,Th52;
  hence thesis by A22,A27,A32,A38,A16,A34,A33,A39,A26,CIRCCOMB:def 2;
end;
