I've been proposed the following exercise:
Let $X,Y\subseteq\mathbb{P}^n_k$ two algebraic sets (non-necessarilly irreducible varieties) of dimension $d$ such that $\dim(X\cap Y)<d$. Show that $\deg(X\cup Y)=\deg(X)+\deg(Y)$.
Using this question I've been able to treat the case where $X$ and $Y$ are irreducible. Now I'm trying to deal with the case where they're not. For this case, the idea is that only the irreducible components of maximal dimension add something to the degree.
Now, let $X=X_1\cup\dots\cup X_r$ a decomposition of $X$ in irreducible components and suppose WLOG that $X_1,\dots, X_i$, $i\leq r$, are those of maximal dimension $d$. Using the same argument of the question I mention above I get to the following point:
$$ P_{X}+P_{\bigcap X_j}=\sum_{j=1}^r P_{X_j} $$
Where $P$ denotes the Hilbert polynomial. On the RHS I know that the leading coefficient is $\sum_{j=1}^i \deg(X_j)/d!$. But on the LHS I've got that intersection. If I could say that the dimension of the intersection is strictly less than $d$, then I would have that $\deg(X)=\sum_{j=1}^i\deg(X_j)$, but I'm not sure about that.
Any ideas of how I could continue?
Edit: I've tried using the whole union instead of dealing with $X$ and $Y$ separately. I denoted $Y_j, j=1,\dots, s$ the irreducible components of $Y$, where $Y_1,\dots, Y_k$ are of dimension $d$.
There, I can say by hypothesis, that $\dim(\bigcap X_j\cap\bigcap Y_j)<d$, and then $\deg(X\cup Y)=\sum_{j=1}^r\deg(X_j)+\sum_{j=1}^k\deg(Y_j)$. Since they're now irreducible, I can say that $\sum_{j=1}^r\deg(X_j)=\deg(\bigcup_{j=1}^r X_j)$ and $\sum_{j=1}^k\deg(Y_j)=\deg(\bigcup_{j=1}^k Y_j)$.
I would need to add the $X_j$ and $Y_j$ that are of lower dimension. Can I do that because they don't change the degree and thus $\deg(\bigcup_{j=1}^k Y_j)=\deg(\bigcup_{j=1}^s Y_j)=\deg(Y)$ (same with $X$)?