Fix y∈B and a real number ε with 0<ε; the point g(y) lies in A. Since g is continuous at y relative to B, for every real number η with 0<η there is a real number δ with 0<δ such that every y′∈B with dY(y,y′)<δ satisfies dX(g(y′),g(y))<η, hence also dX(g(y),g(y′))<η by condition 3 in the definition of a metric. We use this repeatedly.
Claim 1. Suppose u is upper semicontinuous at g(y) relative to A. Choose η with 0<η such that every a∈A with dX(g(y),a)<η satisfies u(a)<u(g(y))+ε, and choose δ for this η as above. If y′∈B and dY(y,y′)<δ, then g(y′)∈A and dX(g(y),g(y′))<η, so
(u∘g)(y′)=u(g(y′))<u(g(y))+ε=(u∘g)(y)+ε.
Hence u∘g is upper semicontinuous at y relative to B. As y∈B was arbitrary, u∘g is upper semicontinuous on B.
Claim 2. Suppose u is lower semicontinuous at g(y) relative to A. Choose η with 0<η such that every a∈A with dX(g(y),a)<η satisfies u(g(y))−ε<u(a), and choose δ for this η. If y′∈B and dY(y,y′)<δ, then as before (u∘g)(y)−ε<(u∘g)(y′). Hence u∘g is lower semicontinuous at y relative to B, and therefore on B.
Claim 3. Suppose u is continuous at g(y) relative to A. Choose η with 0<η such that every a∈A with dX(g(y),a)<η satisfies dR(u(a),u(g(y)))<ε, and choose δ for this η. If y′∈B and dY(y,y′)<δ, then dR((u∘g)(y′),(u∘g)(y))<ε. Hence u∘g is continuous at y relative to B, and therefore on B.
Claim 4. Apply claims 1, 2 and 3 with (Y,dY) taken to be (X,dX), with B taken to be C, and with g:C→X the map g(c)=c. This map satisfies g(c)∈A for every c∈C because C⊆A, and it is continuous on C relative to C: given c∈C and a real number ε with 0<ε, take δ=ε, and note that c′∈C with dX(c,c′)<δ satisfies dX(g(c′),g(c))=dX(c′,c)=dX(c,c′)<ε by condition 3 in the definition of a metric. Since u∘g=u∣C, the three assertions of claim 4 follow.