Claim: If $X=\{0,1\}$ then for any set $A,$ prove that $|X^A|= |P(A)|$ (where, $P(A)$ denotes the power set of $A$).
The proof given was :
If $A=\phi$ then $P(A)=\{\phi\}$ and $X^A$ contains the function $\phi$ and so $|P(A)|=|X^A|.$
Let $A\neq \phi.$ Define a mapping, $\theta:P(A)\to X^A$ as follows:
If $B\subset A$ then, $\psi_B:A\to X$ is
$$\psi_B(x)=1\space \text{if}\space x\in B$$
$$\psi_B(x)=0\space \text{if}\space x\notin B.$$
Clearly, $\psi_B\in X^A.$
We define $\theta(B)=\psi_B,$ then $\theta$ is well-defined for if $B_1=B_2,$ then $\psi_{B_1}=\psi_{B_2}$ i.e $\theta(B_1)=\theta(B_2).$
$\theta$ is one-one for if $B_1\neq B_2$ then $\psi_{B_1}\neq \psi_{B_2}.$
To show, $\theta$ is surjective, let $f\in X^A.$ Then define $B=\{x\in A|f(\alpha)=1\}.$
So, $\theta(B)=\psi_B=f.$ Thus, $\theta$ is a bijection between $X^A$ and $P(A).$
Notation: If S is a set, then by $|S|$ I mean, cardinality of the set $S$. The notation $X^A$ was unknown to me. I found out that $X^A$ is a standard notation, which is used to denote "the set of all functions from $A$ to $X.$"
Even then, I find this proof, unnecessarily lengthy and so, I attempted to devise an alternative proof which might be simpler. Here it is:
We start by proving a lemma that $|A^B|=|A|^{|B|}.$
$A^B$ is the set of all functions from $B$ to $A.$ The set $B$ has $|B|$ number of elements and each such element (say,) $b$ can have $|A|$ number of output values for $f(b)$ under a function say, $f.$ So, the total number of $f's$ possible are, $\underbrace{|A|\times|A|\times\cdots\times |A|}_{\text{|B| times}}=|A|^{|B|},$ which is in fact equal to $|A^B|.$
If $X=\{0,1\}$ then using the above lemma, we have, $$X^A=|X|^{|A|}=2^{|A|}\tag 1.$$
Also, we know that $|P(B)|,$ i.e the number of subsets of $B$ is $2^{|B|}.$ Thus, $|P(A)|=2^{|A|}\tag 2.$
Hence, using the equalities in $(1)$ and $(2)$ we have, $|P(A)|=|X^A|=2^{|A|},$ which is what we were required to prove.
However, I feel that my alternate proof is only valid, if $A,B$ (in the lemma) and $A$ (in the main proof,) are finite sets. Is this a limitation of my arguments ? If this is the case, I want an elaborate explanation why it's not true for infinite sets in general.
If my arguments, are valid with respect to the above (mentioned) respects, any suggestions, to improve this proof, would be appreciated.
The red step is where your proof breaks down:
$$X^A=|X|^{|A|}=2^{|A|} \color{red}{= |P(A)|}$$
The first two steps are fine (your lemma shows the first equality and the second equality holds by applying the definition $\{0,1 \} = 2$). However, nowhere in your proof do you justify the why the red part should hold. If you assume this, then you're correct that the claim can be shown much more directly. However, to prove the claim properly, we typically don't assume that $|P(A)| = 2^{|A|}$ and so we need a bit more work to show that this is actually the case.
We usually just state the $|P(A)| = 2^{|A|}$ without much thought. But when we are asked to prove a claim like this, we need to justify this step. Remember that since the power set is the set of all subsets of $A$, it is not necessarily obvious that the cardinality of this set should be equal to $2^A$ (the set of all functions from $A$ to $2$).
Equally, you are also right that your proof of the lemma does not generalise to infinite cardinalities (although this is a fairly straightforward fix as the lemma holds for all sets without the need for a proof since it is true by definition). The fundamental issue that you will run into is the one above. This will always mean that the proof takes longer and you won't really be able to get it much shorter than the one that you presented above without making the proof harder to follow.