I'm a mathematician and the following came up in my research:
Fix some positive integers $a_0,...,a_n$ and $N$.
Consider subsets $A_i \subset \{0,...,N\}$ where $|A_i|=a_i$, subject to some fixed conditions of the form: $A_{i_0}=A_{j_0}\sqcup A_{j_1}\sqcup ... \sqcup A_{j_t}$. (See an example below).
I want to code an algorithm that takes the values $a_1,...,a_n$, $N$ and the conditions $(i_0, \{j_0,...,j_t\})$, and returns all possible values for the subsets $A_1,...,A_n$.
To be clear, the condition means that $A_{i_0}$ is the union of $A_{j_0},...,A_{j_t}$ and $A_{j_k}\cap A_{j_{k'}}=\emptyset$ for all sets in the RHS.
What's a good way to go about this?
Example: Take $N=1$ and $a_0=a_1=a_3=a_4=1$ and $a_2=2$, subject to: $A_2=A_0\sqcup A_1$, $A_2=A_3\sqcup A_4$. There are exactly 4 such families of subsets:
$A_0=A_3=\{0\}$, $A_1=A_4=\{1\}$, $A_2=\{0,1\}$
$A_0=A_4=\{0\}$, $A_1=A_3=\{1\}$, $A_2=\{0,1\}$
$A_1=A_3=\{0\}$, $A_0=A_4=\{1\}$, $A_2=\{0,1\}$
$A_1 =A_4=\{0\}$, $A_0=A_3=\{1\}$, $A_2=\{0,1\}$
Notes: I suspect the answer is some sort of recursive function, but I haven't been able to do this by myself. I also suspect this can be translated into a graph coloring problem. Incidentally, here is the (as of yet unanswered) math version of this question