reserve x,y,w,z for ExtReal,
  a for Real;

theorem
  x <> -infty & y <> -infty & not ( x = +infty & y = +infty or x =
  -infty & y = -infty ) implies max(x,y) = (x + y + |.x - y.|) / 2
proof
  assume that
A1: x <> -infty and
A2: y <> -infty and
A3: not ( x = +infty & y = +infty or x = -infty & y = -infty );
  per cases;
  suppose
A4: x = +infty;
    then x + y = +infty & x - y = +infty by A2,A3,XXREAL_3:13,def 2;
    then
A5: x + y + |.x - y.| = +infty by XXREAL_3:def 2;
A6: max(x,y) = +infty by A4,XXREAL_0:41;
    thus thesis by A6,A5,XXREAL_3:83;
  end;
  suppose
    x <> +infty;
    then reconsider a = x as Element of REAL by A1,XXREAL_0:14;
      per cases;
      suppose
A7:     y = +infty;
        then x + y = +infty & x - y = -infty by A1,A3,XXREAL_3:13,def 2;
        then
A8:     x + y + |.x - y.| = +infty by XXREAL_3:def 2;
A9:    max(x,y) = +infty by A7,XXREAL_0:41;
        thus thesis by A9,A8,XXREAL_3:83;
      end;
      suppose
        y <> +infty;
        then reconsider b = y as Element of REAL by A2,XXREAL_0:14;
        x - y = a - b by SUPINF_2:3;
        then x + y = a + b & |.x - y.| = |.a-b.| by SUPINF_2:1;
        then
A10:    x + y + |.x - y.| = a + b + |.a-b qua Complex.| by SUPINF_2:1;
        (x + y + |.x - y.|) / 2 = (a+b+|.a-b qua Complex.|)/2 by A10,Th2;
        hence thesis by COMPLEX1:74;
      end;
  end;
end;
