reserve A for non empty closed_interval Subset of REAL;

theorem
for a,b,c be Real st a < b & c > 0
holds centroid (AffineMap (0,c),['a,b']) = (a+b)/2
proof
 let a,b,c be Real;
 assume A1: a < b;
 assume A2: c > 0;
 R1: [#]REAL = REAL by SUBSET_1:def 3;
 R2: ['a,b'] c= REAL;then
 B1: ['a,b'] c= [#]REAL by SUBSET_1:def 3;
 set f = AffineMap (c,0);
 LU1: ['a,b'] = [.(lower_bound ['a,b']),(upper_bound ['a,b']).]
 & ['a,b'] =[.a,b.] by A1,INTEGRA5:def 3,INTEGRA1:4;
 set F = ((c/2) (#) ( #Z 2 ));
 D3: dom ((id REAL) (#) AffineMap (0,c)) = REAL by FUNCT_2:def 1;
 D5A: dom ((c/2) (#) ( #Z 2 )) = REAL by FUNCT_2:def 1;
 D6A: dom ( #Z 2 ) = REAL by FUNCT_2:def 1;
 for x being Real st x in [#]REAL holds ( #Z 2 ) is_differentiable_in x
   by TAYLOR_1:2; then
 C4A: ( #Z 2 ) is_differentiable_on [#]REAL by FDIFF_1:9,D6A; then
 C4: F is_differentiable_on [#]REAL by FDIFF_1:20,D5A; then
 E7: dom (F`|[#]REAL) = [#]REAL by FDIFF_1:def 7;
 C1A:for x being Element of REAL st x in dom (F`|[#]REAL) holds
  (F`|[#]REAL) . x = ((id REAL) (#) AffineMap (0,c)) . x
 proof
  let x be Element of REAL;
  assume E4: x in dom (F`|[#]REAL);
  E3: x in [#]REAL by E4,C4,FDIFF_1:def 7;
  E2: ( #Z 2 ) is_differentiable_in x by TAYLOR_1:2;
  E5:  (F`|[#]REAL).x = diff(((c/2) (#) ( #Z 2 )),x) by FDIFF_1:def 7,C4,E3
  .=(c/2) * diff(( #Z 2 ),x) by FDIFF_1:15,E2
  .= (c/2) * (2 * (x #Z (2 - 1)) ) by TAYLOR_1:2
  .= (c/2) * (2 * x) by PREPOWER:35
  .= c*x;
  ((id REAL) (#) AffineMap (0,c)) . x
   = ((id REAL).x) * (AffineMap (0,c). x) by VALUED_1:5
  .= x * ((0 * x) + c) by FCONT_1:def 4
  .=c*x;
  hence thesis by E5;
 end;
 set F2 = (id REAL) (#) AffineMap (0,c);
 reconsider F2 as PartFunc of REAL,REAL;
 (F2 | ['a,b']) is continuous; then
 (id REAL) (#) AffineMap (0,c) is_integrable_on ['a,b'] &
 (F2 | ['a,b']) is bounded
   by INTEGRA5:10,INTEGRA5:11,D3; then
 C2:  F `| [#]REAL is_integrable_on ['a,b'] &
     (F `| [#]REAL) | ['a,b'] is bounded
        by PARTFUN1:5,SUBSET_1:def 3,D3,E7,C1A;
 C3: integral ((id REAL) (#) AffineMap(0,c),['a,b'])
  = integral ((F `| [#]REAL),['a,b'])
       by PARTFUN1:5,SUBSET_1:def 3,D3,E7,C1A
 .= F . (upper_bound ['a,b']) - F . (lower_bound ['a,b'])
        by INTEGRA5:13,B1,C2,C4A,FDIFF_1:20,D5A
 .=F.b - F . (lower_bound ['a,b']) by LU1,INTEGRA1:5
 .=((c/2) (#) ( #Z 2 )).b - F.a by LU1,INTEGRA1:5
 .=(c/2) * ( #Z 2 ).b - F.a by VALUED_1:6
 .=(c/2) * ( #Z 2 ).b - (c/2) * ( #Z 2 ).a by VALUED_1:6
 .=(c/2) * b #Z 2 - (c/2) * ( #Z 2 ).a by TAYLOR_1:def 1
 .=(c/2) * b #Z 2 - (c/2) * a #Z 2 by TAYLOR_1:def 1
 .=(c/2) * b |^ 2 - (c/2) * a #Z 2 by PREPOWER:36
 .=(c/2) * b |^ 2 - (c/2) * a |^ 2 by PREPOWER:36
 .=(c/2) * b ^2 - (c/2) * a |^ 2 by NEWTON:81
 .=(c/2) * b ^2 - (c/2) * a ^2 by NEWTON:81
 .=((b+a)/2)*(c*(b-a));
 A4: [#] REAL c= dom f by R1,FUNCT_2:def 1;
 A5: for x being Real st x in [#] REAL holds
  (AffineMap (c,0)) . x = (c * x) + 0 by FCONT_1:def 4; then
 B6: AffineMap (c,0) is_differentiable_on [#] REAL by A4, FDIFF_1:23;
 D4: dom (AffineMap (c,0) `| [#]REAL) = [#]REAL by B6,FDIFF_1:def 7;
 then
 dom (AffineMap (c,0) `| [#]REAL) = REAL by SUBSET_1:def 3; then
 B5: dom (AffineMap (c,0) `| [#]REAL) = dom AffineMap(0,c)
  by FUNCT_2:def 1;
 B3A: for x being Element of REAL st
 x in dom (AffineMap (c,0) `| [#]REAL) holds
 (AffineMap (c,0) `| [#]REAL) . x = AffineMap(0,c) . x
 proof
  let x be Element of REAL;
  assume x in dom (AffineMap (c,0) `| [#]REAL); then
  (AffineMap (c,0) `| [#]REAL) . x
  = (0*x) + c by D4,A5,A4, FDIFF_1:23
  .= AffineMap(0,c) . x by FCONT_1:def 4;
  hence thesis;
 end;
 B21: ['a,b'] c= dom (AffineMap(0,c)) by FUNCT_2:def 1,R2;
 set F3 = AffineMap (0,c);
 reconsider F3 as PartFunc of REAL,REAL;
 (F3 | ['a,b']) is continuous; then
 AffineMap(0,c) is_integrable_on ['a,b'] &
 AffineMap(0,c) | ['a,b'] is bounded
    by INTEGRA5:10,INTEGRA5:11,B21; then
 B2: f `| [#]REAL is_integrable_on ['a,b'] &
 (f `| [#]REAL) | ['a,b'] is bounded by B5,PARTFUN1:5,B3A;
 B4: integral (AffineMap(0,c),['a,b'])
  = integral ((f `| [#]REAL),['a,b']) by B5,PARTFUN1:5,B3A
 .= f . (upper_bound ['a,b']) - f . (lower_bound ['a,b'])
   by INTEGRA5:13,B1,B2,A5,A4,FDIFF_1:23
 .= f . b - AffineMap(c,0) . (lower_bound ['a,b']) by LU1,INTEGRA1:5
 .= f . b - AffineMap(c,0) . a by LU1,INTEGRA1:5
 .= (c*b) + 0 - AffineMap(c,0) . a by FCONT_1:def 4
 .= (c*b)  - (c*a+0) by FCONT_1:def 4
 .= c*(b-a);
 a-a < b-a by A1,XREAL_1:9;
 hence centroid (AffineMap (0,c),['a,b'])
   = (a+b)/2 by XCMPLX_1:89,A2,B4,C3;
end;
