 reserve h,h1 for 0-convergent non-zero Real_Sequence,
         c,c1 for constant Real_Sequence;

theorem Th20: ::: generalized ROLLE:8
  for p,q be R_eal, f1,f2 be PartFunc of REAL,REAL
   st f1 is_differentiable_on ].p,q.[ & f2 is_differentiable_on ].p,q.[ &
   (for x be Real st x in ].p,q.[ holds diff(f1,x) = diff(f2,x)) holds
   (f1-f2)|(].p,q.[) is constant &
   ex r be Real st for x be Real st x in ].p,q.[ holds f1.x = f2.x+r
proof
    let p,q be R_eal, f1,f2 be PartFunc of REAL,REAL;
    assume that
A1:  f1 is_differentiable_on ].p,q.[ & f2 is_differentiable_on ].p,q.[ and
A2:  for x be Real st x in ].p,q.[ holds diff(f1,x) = diff(f2,x);

    ].p,q.[ is open_interval by MEASURE5:def 2; then
    reconsider Z=].p,q.[ as open Subset of REAL;
    ].p,q.[ c= dom f1 /\ dom f2 by A1,XBOOLE_1:19; then
A3: ].p,q.[ c= dom (f1-f2) by VALUED_1:12; then
A4: f1-f2 is_differentiable_on Z by A1,FDIFF_1:19;

    now let x be Real;
     assume
A5:   x in ].p,q.[; then
     diff(f1-f2,x) = ((f1-f2)`|Z).x by A4,FDIFF_1:def 7; then
     diff(f1-f2,x) = diff(f1,x)-diff(f2,x) by A1,A3,A5,FDIFF_1:19; then
     diff(f1-f2,x) = diff(f1,x)-diff(f1,x) by A2,A5;
     hence diff(f1-f2,x) = 0;
    end; then
A6: (f1-f2)|Z is constant by A1,A3,Th19,FDIFF_1:19;
    hence (f1-f2)|(].p,q.[) is constant;

    consider r being Element of REAL such that
A7:  for x being Element of REAL st x in ].p,q.[ /\ dom(f1-f2) holds
      (f1-f2).x = r by A6,PARTFUN2:57;
    take r;
    let x be Real;
    assume
A8: x in ].p,q.[; then
    x in ].p,q.[ /\ dom(f1-f2) by A3,XBOOLE_1:28; then
    r = (f1-f2).x by A7; then
    r = f1.x - f2.x by A3,A8,VALUED_1:13;
    hence thesis;
end;
