set A = { a where a is Element of ExtREAL : P1[a] } ;
set B = { a where a is Element of ExtREAL : P2[a] } ;
reconsider X = { a where a is Element of ExtREAL : P1[a] } /\ REAL, Y = { a where a is Element of ExtREAL : P2[a] } /\ REAL as Subset of REAL by XBOOLE_1:17;
per cases ( X = {} or Y = {} or ( X <> {} & Y <> {} ) ) ;
suppose A2: X = {} ; :: thesis: ex s being ExtReal st
( ( for r being ExtReal st P1[r] holds
r <= s ) & ( for r being ExtReal st P2[r] holds
s <= r ) )

per cases ( +infty in { a where a is Element of ExtREAL : P1[a] } or not +infty in { a where a is Element of ExtREAL : P1[a] } ) ;
suppose A3: +infty in { a where a is Element of ExtREAL : P1[a] } ; :: thesis: ex s being ExtReal st
( ( for r being ExtReal st P1[r] holds
r <= s ) & ( for r being ExtReal st P2[r] holds
s <= r ) )

take +infty ; :: thesis: ( ( for r being ExtReal st P1[r] holds
r <= +infty ) & ( for r being ExtReal st P2[r] holds
+infty <= r ) )

thus for r being ExtReal st P1[r] holds
r <= +infty by XXREAL_0:3; :: thesis: for r being ExtReal st P2[r] holds
+infty <= r

ex a being Element of ExtREAL st
( a = +infty & P1[a] ) by A3;
hence for r being ExtReal st P2[r] holds
+infty <= r by A1; :: thesis: verum
end;
suppose A4: not +infty in { a where a is Element of ExtREAL : P1[a] } ; :: thesis: ex s being ExtReal st
( ( for r being ExtReal st P1[r] holds
r <= s ) & ( for r being ExtReal st P2[r] holds
s <= r ) )

take -infty ; :: thesis: ( ( for r being ExtReal st P1[r] holds
r <= -infty ) & ( for r being ExtReal st P2[r] holds
-infty <= r ) )

thus for r being ExtReal st P1[r] holds
r <= -infty :: thesis: for r being ExtReal st P2[r] holds
-infty <= r
thus for r being ExtReal st P2[r] holds
-infty <= r by XXREAL_0:5; :: thesis: verum
end;
end;
end;
suppose A7: Y = {} ; :: thesis: ex s being ExtReal st
( ( for r being ExtReal st P1[r] holds
r <= s ) & ( for r being ExtReal st P2[r] holds
s <= r ) )

per cases ( -infty in { a where a is Element of ExtREAL : P2[a] } or not -infty in { a where a is Element of ExtREAL : P2[a] } ) ;
suppose A8: -infty in { a where a is Element of ExtREAL : P2[a] } ; :: thesis: ex s being ExtReal st
( ( for r being ExtReal st P1[r] holds
r <= s ) & ( for r being ExtReal st P2[r] holds
s <= r ) )

take -infty ; :: thesis: ( ( for r being ExtReal st P1[r] holds
r <= -infty ) & ( for r being ExtReal st P2[r] holds
-infty <= r ) )

ex a being Element of ExtREAL st
( a = -infty & P2[a] ) by A8;
hence for r being ExtReal st P1[r] holds
r <= -infty by A1; :: thesis: for r being ExtReal st P2[r] holds
-infty <= r

thus for r being ExtReal st P2[r] holds
-infty <= r by XXREAL_0:5; :: thesis: verum
end;
suppose A9: not -infty in { a where a is Element of ExtREAL : P2[a] } ; :: thesis: ex s being ExtReal st
( ( for r being ExtReal st P1[r] holds
r <= s ) & ( for r being ExtReal st P2[r] holds
s <= r ) )

take +infty ; :: thesis: ( ( for r being ExtReal st P1[r] holds
r <= +infty ) & ( for r being ExtReal st P2[r] holds
+infty <= r ) )

thus for r being ExtReal st P1[r] holds
r <= +infty by XXREAL_0:3; :: thesis: for r being ExtReal st P2[r] holds
+infty <= r

let r be ExtReal; :: thesis: ( P2[r] implies +infty <= r )
assume A10: P2[r] ; :: thesis: +infty <= r
r in ExtREAL by XXREAL_0:def 1;
then A11: r in { a where a is Element of ExtREAL : P2[a] } by A10;
end;
end;
end;
suppose that A12: X <> {} and
A13: Y <> {} ; :: thesis: ex s being ExtReal st
( ( for r being ExtReal st P1[r] holds
r <= s ) & ( for r being ExtReal st P2[r] holds
s <= r ) )

for x, y being Real st x in X & y in Y holds
x <= y
proof
let x, y be Real; :: thesis: ( x in X & y in Y implies x <= y )
assume x in X ; :: thesis: ( not y in Y or x <= y )
then x in { a where a is Element of ExtREAL : P1[a] } by XBOOLE_0:def 4;
then A14: ex a being Element of ExtREAL st
( a = x & P1[a] ) ;
assume y in Y ; :: thesis: x <= y
then y in { a where a is Element of ExtREAL : P2[a] } by XBOOLE_0:def 4;
then ex a being Element of ExtREAL st
( a = y & P2[a] ) ;
hence x <= y by A1, A14; :: thesis: verum
end;
then consider s being Real such that
A15: for x, y being Real st x in X & y in Y holds
( x <= s & s <= y ) by AXIOMS:1;
reconsider s = s as ExtReal ;
take s ; :: thesis: ( ( for r being ExtReal st P1[r] holds
r <= s ) & ( for r being ExtReal st P2[r] holds
s <= r ) )

thus for r being ExtReal st P1[r] holds
r <= s :: thesis: for r being ExtReal st P2[r] holds
s <= r
proof
let r be ExtReal; :: thesis: ( P1[r] implies r <= s )
consider x being Element of REAL such that
A16: x in Y by A13;
x in { a where a is Element of ExtREAL : P2[a] } by A16, XBOOLE_0:def 4;
then A17: ex a being Element of ExtREAL st
( x = a & P2[a] ) ;
assume A18: P1[r] ; :: thesis: r <= s
end;
let r be ExtReal; :: thesis: ( P2[r] implies s <= r )
consider x being Element of REAL such that
A20: x in X by A12;
x in { a where a is Element of ExtREAL : P1[a] } by A20, XBOOLE_0:def 4;
then A21: ex a being Element of ExtREAL st
( x = a & P1[a] ) ;
assume A22: P2[r] ; :: thesis: s <= r
end;
end;