Problem with Two-valued Measure in Rudin's RCA: Chapter 1, Exercise 6 
Let $X$ be an uncountable set, let $\frak{M}$ be the collection of all sets $E \subseteq X$ such that either $E$ is countable or $E^c$ is countable, and define $\mu (E) = 0$ in the first case, $\mu (E) = 1$ in the second case. Porve that $\frak{M}$ is a $\sigma$-algebra in $X$ and that $\mu$ is a measure on $\frak{M}$. Describe the corresponding measurable functions and their integrals. 

I have already worked on the first part, but I am having trouble describing the measurable functions and their integrals, so I consulted this solution, but I am having trouble following it(see page 3). Here is the relevant passage:

The measurable functions on $\frak{M}$ consist of those functions $f : X \to \Bbb{R}$ such that for each $r \in \Bbb{R}$, $f^{-1}(r)$ is at most countable or $f^{-1}(\Bbb{R}- \{r\})$ is at most countable. If we let $A \subseteq \Bbb{R}$ denote the set of points such that $f^{-1}(r)$ is not countable, then the integral of $f$ is $\sum_{r \in A} r$. 

First let's compute the integral of a simple function $s(x) = \sum_{i=1}^n a_i 1_{A_i}(x)$, where the $A_i$ are pairwise disjoint, measurable sets and $X = \bigcup_{i=1}^n A_i$. Then $A_k$ must be uncountable and therefore $A_k^c$ is countable. Then $A_i \cap A_k = \emptyset$ for every $i \neq k$ implies $A_i^c \cup A_k^c = X$ for $i \neq k$ and therefore $A_i$ is uncountable for every $i\neq k$. Hence $\mu(A_i) = 0$ and therefore $\mu(X \cap A_i) = 0$ for $i\neq k$, and $\mu(X \cap A_k)=0$. Hence, $\displaystyle \int_X s d \mu = \sum_{i=1}^n a_i \mu(X \cap A_i)= a_k$. 
Now, if $f$ is measurable, then I agree with the above quote that either $f^{-1}(r)$ or $f^{-1}(\Bbb{R}-\{r\})$ is countable for every $r \in \Bbb{R}$. However, I don't see how 
$$\int_X f d \mu = \sup \{ \int s d \mu \mid s \text{ simple, } 0 \le s \le f \}$$
$$= \sup \{ a \in \Bbb{R} \mid 0 \le a \le f(x)~ \forall x \in x \}$$
equals the sum $\sum_{r \in A} r$. 
Also, I found this MSE post, but I don't quite understand Daniel Robert-Nicoud answer, particularly the second point he makes which is 

Assume there is no such $x$. Then $f$ defines a partition of $X$ into at most countable sets by $\bigsqcup_{x\in\mathbb{R}}E_x = X$. By cardinality arguments, there must be an uncountable number of sets in the partition. In particular, $f(X)$ is an uncountable subset of $\mathbb{R}$, and as such it has uncountably many limit points. From this, you should be able to prove that such a function cannot exist (else you would be able to construct two disjoint uncountable subsets of $X$ that are both in $\mathfrak{M}$). 

What exactly are these "cardinality arguments" leading to the conclusion "there must be an uncountable number of sets in the partition"? And how does this "in particular" imply $f(X)$ is uncountable? The $E_x$ are preimages, while $f(X)$ is an image...
EDIT:
Here is something I tried. Note that $f^{-1}([x,x+1))$ is measurable for every $x \in \Bbb{Z}$, and $X = \bigcup_{x \in \Bbb{Z}} f^{-1}([x,x+1))$ which means that $f^{-1}([x,x+1))$ is uncountable for some integer $x$. This means that its complement is countable and therefore $\mu(f^{-1}([x,x+1)) = 1$. Since the complement is countable, $f^{-1}([x,x+1)) \cap  f^{-1}([y,y+1)) = \emptyset$, where $x= \neq u$, implies $f^{-1}([x,x+1)^c) \cup f^{-1}([y,y+1)^c)$ = X which implies $f^{-1}([y,y+1)^c)$ is uncountable and therefore $f^{-1}([y,y+1))$ is countable, which means $\mu (f^{-1}([y,y+1)) =0$. Hence, the integral of $f$ is (I believe):
$$\int_X f d \mu = \int_{\bigcup f^{-1}([z,z+1))} f d \mu = \sum_{z \in \Bbb{Z}} \int_{f^{-1}([z,z+1))} f d \mu = \int_{f^{-1}([x,x+1))} f d \mu $$
Of course, assuming that is right, I still need to evaluate $\int_{f^{-1}([x,x+1))} f d \mu$ which I am unable to do at the moment. 
 A: Part I: Typos and mistakes in your attempts
Let me first point out it appears you have a typo in the sentence

Then $A_i \cap A_k = \emptyset$ for every $i \neq k$ implies $A_i^c \cup A_k^c = X$ for $i \neq k$ and therefore $A_i$ is uncountable for every $i \neq k$.

You must have meant to say

. . . and therefore $A_i$ is countable for every $i \neq k$.

Secondly, there is no need to write that the integral of the simple function $s(x) = \sum_{i=1}^n a_i 1_{A_i}(x)$ over $X$ w.r.t. the measure $\mu$ is
$$
\int_X s\, d\mu = \sum_{i=1}^n a_i \mu(A_i \cap X);
$$
you can simply write $\mu(A_i)$ in place of $\mu(A_i \cap X)$ since $A_i \cap X = A_i$ for all $1 \leq i \leq n$. Only when you are integrating over a proper subset of $X$, say $E$, do you need to carefully specify that the integral is $\sum_{i=1}^n a_i \mu(A_i \cap E)$.
Thirdly, the set
$$
\sup \{ a \in \Bbb{R} \mid 0 \leq a \leq f(x) \ \forall x \in X \} \qquad (\text{note the typo: you have } x \in x)
$$
is not clearly expressed. I presume that $a$ is meant to be independent of $x$, in which case this set is just $\inf\{ f(x) : x \in X \}$, and we definitely don't have equality between this set and
$$
\sup \{ \int s\, d\mu \mid s \text{ simple, } 0 \leq s \leq f \}.
$$
Lastly, in your edit, the following part is completely unclear to me.

Since the complement is countable, $f^{-1}([x,x+1)) \cap  f^{-1}([y,y+1)) = \emptyset$, where $x= \neq u$, implies $f^{-1}([x,x+1)^c) \cup f^{-1}([y,y+1)^c)$ = X which implies $f^{-1}([y,y+1)^c)$ is uncountable and therefore $f^{-1}([y,y+1))$ is countable, which means $\mu (f^{-1}([y,y+1)) =0$.

Perhaps the argument can be fixed, but as it stands it does not make sense. For instance, it is false that $f^{-1}([x,x+1)) \cap  f^{-1}([y,y+1)) = \emptyset$.

Part II: About your questions on @DanielRobert-Nicoud's answer
We assume that $f \colon X \to \Bbb{R}$ is measurable and for each $x \in \Bbb{R}$ we define $E_x \in \mathfrak{M}$ by $E_x = f^{-1}(x)$. Suppose there is no $x \in \Bbb{R}$ such that $E_x$ is uncountable. Then, we have $X = \bigsqcup_{x \in \Bbb{R}} E_x$ with each $E_x$ being at most countable.
Note that many of the sets $E_x$ can be empty. If there were at most countably many $x \in \Bbb{R}$ such that $E_x \neq \emptyset$, then $\bigsqcup_{x \in \Bbb{R}} E_x$ would be countable, which is a contradiction. These are the "cardinality arguments" that show that there must be uncountably many nonempty sets in this partition of $X$.
In fact, let us examine this more carefully. For each point $x$ in the image $f(X) \subset \Bbb{R}$, we have a distinct nonempty measurable set $E_x \subset X$. What we have just concluded is that there are uncountably many $x \in \Bbb{R}$ such that $E_x$ is nonempty. Moreover, $E_x$ is nonempty only if $x$ lies in the image of $f$, by definition of $E_x$. Both facts together can be summarised by saying, we have uncountably many $x \in f(X)$. This is the claim that was made after saying, "In particular".

Part III: My solution
I will note that the first solution you have quoted from an online resource is unsatisfactory. It hardly tells us anything more than the definition of a measurable function in this particular case. Same for the description of the integral.
@DanielRobert-Nicoud's answer is accurate. I would like to give a proof in my own words though, just for my satisfaction.
Since any measurable $f \colon X \to \Bbb{R}$ can be written as $f = f^+ - f^-$, let us first try to describe $f$ when it is positive, that is, when its range lies in $[0,\infty)$. In this case, we know that $f$ is the pointwise limit of a monotonically increasing sequence of positive simple functions. So, let us take $s \colon X \to \Bbb{R}$ to be a positive simple function. We can write
$$
s = \sum_{i=1}^n \alpha_i \chi_{A_i}, \qquad A_i \in \mathfrak{M},\alpha_i \geq 0.
$$
We assume that the $A_i$ are pairwise disjoint. So, precisely one $A_i$ has at most countable complement, while the rest are themselves at most countable.
Now, let $s_n \colon X \to \Bbb{R}$ be a simple function for each $n \in \Bbb{N}$ such that $0 \leq s_1 \leq s_2 \leq \dots \leq f$ and $\lim_{n \to \infty} s_n(x) = f(x)$ for all $x \in X$. To each $s_n$ we associate the unique measurable set of at most countable complement that we discussed above, and we shall denote it by $E_n$. Let $\alpha_n = s_n(x)$ for any $x \in E_n$. Then, we have that
$$
0 \leq \alpha_1 \leq \alpha_2 \leq \dots \leq f(x) \quad \text{ for all }\quad x \in E := \bigcap_{n=1}^\infty E_n,
$$
and $\lim_{n \to \infty} \alpha_n = f(x)$ for all $x \in E$. Note that $E$ has at most countable complement. The same observation holds for an arbitrary measurable function $f$ (that is, not necessarily positive measurable function). Hence, if $f \colon X \to \Bbb{R}$ is a measurable function, $f$ must be constant on an uncountable measurable set.
The converse is also true. If $f$ is constant on $E$, an uncountable measurable set, then for any definition of $f(x)$ for the points $x \in X - E$, we can show that $f$ turns out to be measurable. Indeed, since $X - E$ is countable, it has an enumeration, say $\{ x_n \}_{n \in \Bbb{N}}$. Assume that $f$ is a positive measurable function. Suppose we define $f(x_n) = \alpha_n \geq 0$ and $f(x) = \alpha \geq 0$ for $x \in E$. Then, we define $s_n \colon X \to \Bbb{R}$ by
$$
s_n = \alpha \chi_E + \sum_{i=1}^n \alpha_i \chi_{\{x_i\}}.
$$
It is easy to see that $0 \leq s_1 \leq s_2 \leq \dots \leq f$ and $\lim_{n \to \infty} s_n(x) = f(x)$ for all $x \in X$.
With this description of $f$, the integral of $f$ becomes simple to evaluate: it is just $\alpha$, the constant value that $f$ takes on an uncountable measurable set.

Note that it is still true that the integral of $f$ is
$$
\sum_{r \in A} r,
$$
where $A \subset \Bbb{R}$ is the set of points $r \in \Bbb{R}$ such that $f^{-1}(r)$ is uncountable. It is just that $A$ is the singleton set $\{ \alpha \}$, so the summation is quite trivial.
