reserve x,y,z,w for ExtReal,
  r for Real;
reserve f,g for ExtReal;

theorem
  (x = +infty & y = +infty implies 0 <= z) & (x = -infty & y = -infty
  implies 0 <= z) implies (x <= z + y implies x - y <= z)
proof
  assume that
A1: x = +infty & y = +infty implies 0 <= z and
A2: x = -infty & y = -infty implies 0 <= z and
A3: x <= z + y;
  per cases by XXREAL_0:14;
  suppose
A4: x = +infty;
    per cases by A3,A4,Lm8,XXREAL_0:4;
    suppose
      z = +infty;
      hence thesis by XXREAL_0:3;
    end;
    suppose
      y = +infty;
      hence thesis by A1,A4,Th7;
    end;
  end;
  suppose
A5: x = -infty;
    per cases;
    suppose
      y = -infty;
      hence thesis by A2,A5,Th7;
    end;
    suppose
      --y <> -infty;
      then -y <> +infty by Def3;
      then x - y = -infty by A5,Def2;
      hence thesis by XXREAL_0:5;
    end;
  end;
  suppose
A6: x in REAL;
    per cases by A3,A6,XXREAL_0:10;
    suppose
A7:   z + y in REAL;
      per cases by A7,Th20;
      suppose
        y = +infty;
        then x - y = -infty by A6,Def2,Th5;
        hence thesis by XXREAL_0:5;
      end;
      suppose
        z = +infty;
        hence thesis by XXREAL_0:3;
      end;
      suppose
        z in REAL & y in REAL;
        then reconsider a = x, b = y, c = z as Element of REAL by A6;
        a <= b + c by A3;
        then a - b <= c by XREAL_1:20;
        hence thesis;
      end;
    end;
    suppose
A8:   z + y = +infty;
      per cases by A8,Lm8;
      suppose
        z = +infty;
        hence thesis by XXREAL_0:3;
      end;
      suppose
        y = +infty;
        then x - y = -infty by A6,Def2,Th5;
        hence thesis by XXREAL_0:5;
      end;
    end;
  end;
end;
