TITLE: Constructing a family of sets
QUESTION [7 upvotes]: I am completely stuck at the following question.
Suppose $X$ is an infinite set. Show that there is a family $\mathcal{F}$ of subsets of $X$ satisfying the following:
(a) If $A \subseteq X$ is finite, then $A \in \mathcal{F}$ iff $|A|$ is even.
(b) If $A, B$ are disjoint subsets of $X$, then $A \cup B \in \mathcal{F}$ iff either $A, B $ are both in $\mathcal{F}$ or $A, B$ are both not in $\mathcal{F}$. 
What I tried: I started by adding all even size sets to $\mathcal{F}$ and then tried to use Zorn's lemma but could not come up with a partial order to make it work. 
Could someone give me any hints? Thanks!

REPLY [4 votes]: Let $[X]^{\lt\omega}$ be the set of all finite subsets of $X$. Let $\mathcal U$ be an ultrafilter on $[X]^{\lt\omega}$ such that $\{E\in[X]^{\lt\omega}:x\in E\}\in\mathcal U$ for each $x$ in $X$. Let's say that a statement $P(E)$ holds for almost all $E\in[X]^{\lt\omega}$ if $\{E\in[X]^{\lt\omega}:P(E)\}\in\mathcal U$. Now define
$$\mathcal F=\{A\subseteq X:|A\cap E|\text{ is even for almost all }E\in[X]^{\lt\omega}\}.$$
Then (a) and (b) are satisfied.
More generally: For any positive integer $n$ and any set $A$, there is a function $f:\mathcal P(A)\to\{0,\dots,n-1\}$ satisfying the conditions:
(1) $f(X)\equiv|X|\pmod n$ for every finite set $X\subseteq A$;
(2) if $X,Y\subseteq A$ and $X\cap Y=\emptyset$, then $f(X\cup Y)\equiv f(X)+f(Y)\pmod n$.