Throughout, order and addition arithmetic in R is taken from Elementary Order Arithmetic in an Ordered Field, whose claim 1 is strict compatibility of < with addition, claim 2 is mixed transitivity of < and ≤, and claim 3 is addition of inequalities; and −(−t)=t for t∈R by claim 5 of Additive Cancellation and Elementary Additive Identities in a Field.
Claim 1. Suppose first that u is upper semicontinuous at x relative to A, and let ε∈R with 0<ε. Choose δ∈R with 0<δ such that every y∈A with dX(x,y)<δ satisfies u(y)<u(x)+ε. Fix such a y. Adding −u(x)−u(y)−ε to both sides of u(y)<u(x)+ε and using claim 1 of the order arithmetic lemma gives
−u(x)−ε<−u(y),
that is, (−u)(x)−ε<(−u)(y). As ε was arbitrary, −u is lower semicontinuous at x relative to A.
Conversely, suppose −u is lower semicontinuous at x relative to A, let ε∈R with 0<ε, and choose δ with 0<δ such that every y∈A with dX(x,y)<δ satisfies −u(x)−ε<−u(y). Adding u(x)+u(y)+ε to both sides and using claim 1 of the order arithmetic lemma gives u(y)<u(x)+ε. Hence u is upper semicontinuous at x relative to A. This proves the first equivalence.
Applying the first equivalence to the function −u in place of u gives: −u is upper semicontinuous at x relative to A if and only if −(−u) is lower semicontinuous at x relative to A. Since −(−u) and u take the same value at every point of A, they are the same function, and the second equivalence follows.
Claim 2. Suppose u is upper semicontinuous at x relative to A and let ε∈R with 0<ε. Choose δ with 0<δ such that every y∈A with dX(x,y)<δ satisfies u(y)<u(x)+ε. If z∈A′ satisfies dX(x,z)<δ, then z∈A because A′⊆A, so u(z)<u(x)+ε; since u∣A′(z)=u(z) and u∣A′(x)=u(x), this reads u∣A′(z)<u∣A′(x)+ε. Hence u∣A′ is upper semicontinuous at x relative to A′. The lower semicontinuous case is identical, with the inequality u(x)−ε<u(y) in place of u(y)<u(x)+ε.
Claim 3. Suppose u is upper semicontinuous at x relative to A and w is lower semicontinuous at x relative to A. By claim 1, −w is upper semicontinuous at x relative to A. For every z∈A we have u(z)+(−w)(z)=u(z)+(−w(z))=u(z)−w(z), so u−w is the pointwise sum of u and −w in the sense of Sums and Nonnegative Multiples of Semicontinuous Functions; by claim 1 of that lemma, u−w is upper semicontinuous at x relative to A.
Suppose instead that u is lower semicontinuous at x relative to A and w is upper semicontinuous at x relative to A. By claim 1, −w is lower semicontinuous at x relative to A, and by claim 3 of Sums and Nonnegative Multiples of Semicontinuous Functions the pointwise sum u−w of u and −w is lower semicontinuous at x relative to A.
Claim 4. Let (x0,y0)∈A×B and let ε∈R with 0<ε. By claim 8 of Elementary Order Arithmetic in an Ordered Field there is η∈R with 0<η and η+η=ε.
Since f is upper semicontinuous at x0 relative to A, there is δ1∈R with 0<δ1 such that every x∈A with dX(x0,x)<δ1 satisfies f(x)<f(x0)+η. Since g is lower semicontinuous at y0 relative to B, there is δ2∈R with 0<δ2 such that every y∈B with dY(y0,y)<δ2 satisfies g(y0)−η<g(y).
Let δ be the minimum of δ1 and δ2. By claim 2 of Elementary Properties of the Minimum of Two Elements, δ equals δ1 or δ2, so 0<δ; and by claim 1 of that lemma, δ≤δ1 and δ≤δ2.
Let (x,y)∈A×B satisfy dX×Y((x0,y0),(x,y))<δ. By the definition of the product metric, dX×Y((x0,y0),(x,y)) is the maximum of dX(x0,x) and dY(y0,y), so by claim 1 of Elementary Properties of the Maximum of Two Elements,
dX(x0,x)≤dX×Y((x0,y0),(x,y)),dY(y0,y)≤dX×Y((x0,y0),(x,y)).
By claim 2 of the order arithmetic lemma these give dX(x0,x)<δ and dY(y0,y)<δ, and then, again by claim 2, dX(x0,x)<δ1 and dY(y0,y)<δ2. Consequently
f(x)<f(x0)+η,g(y0)−η<g(y).
Adding −g(y0)−g(y)+η to both sides of the second inequality and using claim 1 of the order arithmetic lemma gives −g(y)<−g(y0)+η. Adding this to the first inequality by claim 3 of the order arithmetic lemma gives
f(x)−g(y)<f(x0)+η+(−g(y0)+η)=f(x0)−g(y0)+ε,
where the last equality uses η+η=ε and commutativity and associativity of addition. That is, h(x,y)<h(x0,y0)+ε.
Since ε was arbitrary, h is upper semicontinuous at (x0,y0) relative to A×B, and since (x0,y0) was an arbitrary point of A×B, h is upper semicontinuous on A×B.