Criteria for connectedness

I have to prove that if, X is not the union of two disjoint non-empty closed subsets of itself, then,

Either X is empty or the only continuous functions from X to the discrete space {0,1} are the two constant functions.

Attempt at the proof:

Assume that the first one is true, and let f:X->{0,1} be continuous.

Then f inverse of zero and f inverse of one are both disjoint and closed in X.

How do i proceed further ?

Re: Criteria for connectedness

I don't understand what you mean by "Assume that the first one is true". You should assume that cannot be represented as the union of two disjoint non-empty closed subsets of itself. Then, also assume is nonempty (so, either is empty, in which case the proposition is true, or is nonempty, and you are in this case) and prove that the only continuous functions from to the discrete space are the two constant functions. As you said, define as a continuous function. You learned that a function is continuous if the preimage of every closed set is closed. Since and , both singleton sets are clopen (both open and closed) subsets of . Since is continuous, and must both be closed. Suppose . Then and , implying is not even a function. So, the preimages must be disjoint. For any , either or , so the union of the preimages must be the entire set. Suppose . Then by the initial assumption ( cannot be represented by the union of two disjoint, nonempty, closed subsets of itself), it must be that . The other case: . By the second assumption, is nonempty, so it must be that . Hence, either or .