Let $\displaystyle M$ be a set composed of $\displaystyle n$ elements and let $\displaystyle \mathcal P (M)$ be its power set. Find all functions $\displaystyle f : \mathcal P (M) \to \{ 0,1,2,\ldots,n \}$ that have the properties

(a) $\displaystyle f(A) \neq 0$, for $\displaystyle A \neq \phi$;

(b) $\displaystyle f \left( A \cup B \right) = f \left( A \cap B \right) + f \left( A \Delta B \right)$, for all $\displaystyle A,B \in \mathcal P (M)$, where $\displaystyle A \Delta B = \left( A \cup B \right) \backslash \left( A \cap B \right)$.
1. **Define the problem and given conditions:**
   - Let \( M \) be a set with \( n \) elements.
   - Let \( \mathcal{P}(M) \) be the power set of \( M \).
   - We need to find all functions \( f: \mathcal{P}(M) \to \{0, 1, 2, \ldots, n\} \) that satisfy:
     - (a) \( f(A) \neq 0 \) for \( A \neq \emptyset \).
     - (b) \( f(A \cup B) = f(A \cap B) + f(A \Delta B) \) for all \( A, B \in \mathcal{P}(M) \), where \( A \Delta B = (A \cup B) \setminus (A \cap B) \).

2. **Initial observations:**
   - Consider \( X \) and \( Y \) as two disjoint subsets of \( M \). Let \( A = X \cup Y \) and \( B = X \).
   - Using the given property (b):
     \[
     f(A \cup B) = f(A \cap B) + f(A \Delta B)
     \]
     Substituting \( A = X \cup Y \) and \( B = X \):
     \[
     f((X \cup Y) \cup X) = f((X \cup Y) \cap X) + f((X \cup Y) \Delta X)
     \]
     Simplifying the expressions:
     \[
     f(X \cup Y) = f(X) + f(Y)
     \]

3. **Induction for pairwise disjoint subsets:**
   - By induction, for any pairwise disjoint subsets \( X_1, X_2, \ldots, X_k \):
     \[
     f\left(\bigcup_{i=1}^k X_i\right) = \sum_{i=1}^k f(X_i)
     \]

4. **Base case:**
   - For the empty set \( \emptyset \):
     \[
     f(\emptyset) = 0
     \]
     This is because \( f \) maps to \( \{0, 1, 2, \ldots, n\} \) and \( f(A) \neq 0 \) for \( A \neq \emptyset \).

5. **Function evaluation for singletons:**
   - For any singleton set \( \{x_i\} \):
     \[
     f(\{x_1, x_2, \ldots, x_m\}) = \sum_{i=1}^m f(\{x_i\})
     \]
     By property (a), \( f(\{x_i\}) \geq 1 \) for all \( i \).

6. **Summing over all elements:**
   - For the entire set \( M \):
     \[
     f(M) = f(\{x_1, x_2, \ldots, x_n\}) = \sum_{i=1}^n f(\{x_i\})
     \]
     Since \( f(\{x_i\}) \geq 1 \):
     \[
     f(M) \geq \sum_{i=1}^n 1 = n
     \]
     Given \( f \) maps to \( \{0, 1, 2, \ldots, n\} \), we also have \( f(M) \leq n \). Therefore, equality must hold:
     \[
     f(M) = n
     \]

7. **Equality condition:**
   - Equality holds if and only if \( f(\{x_i\}) = 1 \) for all \( i \in \{1, 2, \ldots, n\} \).
   - Thus, for any subset \( X \subseteq M \):
     \[
     f(X) = |X|
     \]

8. **Verification:**
   - The function \( f(X) = |X| \) satisfies all given conditions:
     - \( f(A) \neq 0 \) for \( A \neq \emptyset \).
     - \( f(A \cup B) = f(A \cap B) + f(A \Delta B) \).

\(\blacksquare\)

The final answer is \( \boxed{ f(X) = |X| } \).