Write Tdβ for the collection of subsets of X that are open in (X,d), a topology by Metric Open Sets Form a Topology, and TKβ={Kβ©W:WβTdβ} for the subspace topology on K. By the definition of a compact subset, the hypothesis on K says that the topological space (K,TKβ) is compact. For a natural number n, [n] is the initial segment determined by n. We use the ordered field structure of R, whose order β€ is in particular a total order, hence reflexive, antisymmetric, transitive and comparing any two elements, and we write s<t to mean sβ€t and sξ =t. We also use the properties of the absolute value recorded in Properties of the Absolute Value in an Ordered Field, in particular tβ€β£tβ£ and β£βtβ£=β£tβ£ for every real t.
Step 1: for every real c the set Vcβ={yβK:f(y)<c} belongs to TKβ.
For each xβVcβ we have f(x)<c, hence 0<cβf(x), so the continuity hypothesis provides a real Ξ΄xβ>0 such that every yβK with d(x,y)<Ξ΄xβ satisfies β£f(y)βf(x)β£<cβf(x); since f(y)βf(x)β€β£f(y)βf(x)β£, such a y satisfies f(y)βf(x)<cβf(x) and therefore f(y)<c, using compatibility of the order with addition (condition 1 of Ordered Field). Let
Wcβ=xβVcβββBdβ(x,Ξ΄xβ)
be the union of the family of open balls Bdβ(x,Ξ΄xβ) indexed by xβVcβ.
The set Wcβ is open in (X,d). Indeed, let zβWcβ, say zβBdβ(x,Ξ΄xβ) with xβVcβ, and put r=Ξ΄xββd(x,z), which satisfies r>0 because d(x,z)<Ξ΄xβ. If wβBdβ(z,r), then the triangle inequality of Metric Space gives d(x,w)β€d(x,z)+d(z,w)<d(x,z)+r=Ξ΄xβ, so Bdβ(z,r)βBdβ(x,Ξ΄xβ)βWcβ.
Moreover Kβ©Wcβ=Vcβ. If yβKβ©Wcβ then yβBdβ(x,Ξ΄xβ) for some xβVcβ, so d(x,y)<Ξ΄xβ and hence f(y)<c by the choice of Ξ΄xβ, that is yβVcβ. Conversely, if xβVcβ then xβK and d(x,x)=0<Ξ΄xβ, so xβBdβ(x,Ξ΄xβ)βWcβ. Hence Vcβ=Kβ©WcββTKβ.
Step 2: f attains a maximum.
Suppose not: suppose there is no xmaxββK with f(x)β€f(xmaxβ) for every xβK. Then for every xβK there is yβK for which f(y)β€f(x) fails. For such x and y we get f(x)β€f(y) by comparability, and f(x)ξ =f(y) because f(x)=f(y) would give f(y)β€f(x) by reflexivity; that is, f(x)<f(y).
Consider the family (Vf(y)β)yβKβ of subsets of K indexed by the set K. Each member belongs to TKβ by Step 1, and the family covers K: given xβK, choose yβK with f(x)<f(y); then xβVf(y)β. Since (K,TKβ) is compact, there are a natural number n and elements y1β,β¦,ynββK with
KβVf(y1β)ββͺβ―βͺVf(ynβ)β.
Apply Greatest Element of a Finite Family in a Totally Ordered Set to the set R with its total order and to the n-tuple in R whose k-th component is f(ykβ): there is jβ[n] with f(ykβ)β€f(yjβ) for every kβ[n]. Since yjββK, there is kβ[n] with yjββVf(ykβ)β, that is f(yjβ)<f(ykβ), so f(yjβ)β€f(ykβ) and f(yjβ)ξ =f(ykβ). Together with f(ykβ)β€f(yjβ), antisymmetry of the total order gives f(yjβ)=f(ykβ), a contradiction.
Hence the supposition was false, and there exists xmaxββK such that f(x)β€f(xmaxβ) for every xβK.
Step 3: f attains a minimum.
Let g:KβR be defined by g(x)=βf(x), the additive inverse in R. For x,yβK we have g(y)βg(x)=β(f(y)βf(x)), hence β£g(y)βg(x)β£=β£f(y)βf(x)β£, so g satisfies the same continuity hypothesis as f, with the same Ξ΄ for each x and Ξ΅. By Step 2 applied to g there is xminββK with g(x)β€g(xminβ) for every xβK, that is βf(x)β€βf(xminβ). Adding f(x)+f(xminβ) to both sides and using compatibility of the order with addition (condition 1 of Ordered Field) gives f(xminβ)β€f(x) for every xβK.
Steps 2 and 3 together give the assertion.