Proof Verification for Extreme Value Theorem

I had an idea for a proof of the Extreme Value Theorem, and I was wondering if it was valid. Any advice you have would be greatly appreciated. Thank you!

Prove: If a function f(x) is continuous on a closed interval [a,b], then f(x) has both a maximum and a minimum on [a,b]

Proof: Case 1: f is constant on [a,b]

If f is constant, then for any $$x_1$$ < $$x_2$$, f($$x_1$$) = f($$x_2$$). Therefore, f($$x_1$$) ≥ f($$x_2$$) and f($$x_1$$) ≤ f($$x_2$$). So, by definition of maxima and minima, f has at least one of both on [a,b]. This satisfies the theorem.

Case 2: f is strictly increasing or strictly decreasing on [a,b]:

Let's start with strictly increasing. By definition, for each $$x_1$$ < $$x_2$$, f($$x_1$$) ≤ f($$x_2$$). Because x < b for any x in (a,b), f(x) ≤ f(b). so the endpoint f(b) is a maximum on f on [a,b]. We also know that, because a < x for any x in (a,b), f(a) ≤ f(x). So f(a) is a minimum on [a,b]. This satisfies the theorem. The case for a strictly decreasing function f on [a,b] is similar.

Case 3: f is both strictly increasing and strictly decreasing on [a,b]

Divide the open interval (a,b) into smaller subintervals $$U_i$$ and $$D_i$$. On $$U_i$$, f is strictly increasing and possibly constant, and on $$D_i$$, f is strictly decreasing and possibly constant. Construct the subintervals so that, if there is a constant section of the graph in a subinterval, it is near the right endpoint of the respective subinterval. Each $$U_i$$ is followed by a $$D_i$$, and vice versa.

Assume the function has at least one strictly increasing interval. By the argument for case 2, at the right endpoint of all subintervals $$U_i$$, the value will be a maximum $$M_i$$. If f is constant near the right endpoint, the right endpoint is still a max for the total interval $$U_i$$ by the definition of a maximum. Because each interval $$U_i$$ is followed by an interval $$D_i$$, and because f is strictly decreasing on the neighboring $$D_i$$, $$M_i$$ will be a maximum for the combined interval $$D_i$$ + $$M_i$$. Adding all combined intervals $$D_i$$ + $$M_i$$ gives (a,b), so the largest $$M_i$$ found will be the total maximum/maxima of f on (a,b). Let S = {$$M_i$$ | $$i∈ℕ$$, $$M∈f$$ }. Because every continuous function is bounded, the maxima of f must also be bounded, so S is bounded above. We know S is non-empty because we assume there is at least one strictly increasing interval $$U_i$$, and therefore at least one $$M_i$$ in (a,b). Therefore by the Supremum Axiom, there must be a $$M_{max}$$$$M_i$$ for all maxima in S. The endpoints f(a) and f(b) may be greater than the $$M_{max}$$, so the endpoints must be compared with $$M_{max}$$, but no matter the outcome of the comparison, there will still be at least one maximum for f on [a,b].

So, f has at least one maximum on [a,b] if it is strictly increasing on at least one subinterval of (a,b). The proof for f having at least one minimum on [a,b], assuming it is strictly decreasing on at least one subinterval of (a,b), is similar.

This concludes the proof.