Filling cups and buckets continuously There are seven cups, each with a water tap that adds water into it at the same rate. There are also three buckets. At any point, if any of these conditions is met, you pour water from the cups into the buckets according to the following rules:

*

*If there is one unit of water in cups $1,2,3,4$ combined, you pour all that water into the first bucket.

*If there is one unit of water in cups $4,5,6$ combined, you pour all that water into the second bucket.

*If there is one unit of water in cups $6,7$ combined, you pour all that water into the third bucket.

As time goes on, what does the ratio between water in the three buckets converge to?
My computer program shows that it the limit of this ratio is $9:4:4$, but it is not clear to me how to prove it formally. Can we set up some kind of "steady-state" equations? More interestingly, can we determine the answer $9:4:4$ without using a program?
 A: I only have a terrible proof that the pattern continues.
If the cups are in a state $(a,a,a,a,b,0,0)$ with $\frac1{12} < a \le \frac18$ and $\frac{788a-61}{148} \le b \le \frac{8a+1}{4}$, then $17$ steps later they end up in the state $(a',a',a',a',b',0,0)$ with $a' = \frac{3644 a-640 b+1805}{20736}$ and $b' = \frac{320 a-49 b+2117}{5184}$, adding $9$ units of water to the first bucket and $4$ units of water to each of the other two. The new $a'$ and $b'$ also satisfy the inequalities we assumed about $a$ and $b$.
Moreover, after $17$ steps from the state $(0,0,0,0,0,0,0)$, we arrive at a state $(a,a,a,a,b,0,0)$ with $a = \frac{1805}{20736}$ and $b = \frac{2117}{5184}$, adding $9$ units of water to the first bucket and $4$ units of water to each of the other two. These values of $a$ and $b$ satisfy the inequalities in the previous paragraph.
All this could in theory be checked by hand, very painfully; it requires verifying a finite number of inequalities at each of the $17$ steps. Of course, I did it in Mathematica.
As a point of curiosity, if the cups are at some point in the state
$$ \left(\frac{99885}{1106756}, \frac{99885}{1106756}, \frac{99885}{1106756}, \frac{99885}{1106756}, \frac{113461}{276689}, 0,0\right)
$$
then $17$ steps later they return to that exact state, adding $9$ units of water to the first bucket and $4$ units of water to each of the other two. This state is the limit of the $17$-step cycle we're looking at above.
A: I think you can show this using Birkhoff's ergodic theorem. Represent the amount of water in the first three glasses as $x_1$, and the amount of water in glass $i$ for $i \ge 4$ as $x_{i-2}$. Then you can treat the amount of water in all the glasses as a point $x \in \mathbb{R}^5$. You can define a function $f:\mathbb{R}^5 \to \mathbb{R}^5$ by saying $f(x)$ is the amount of water in each glass just before you empty a bucket (let's assume the starting amounts of water in each glass aren't rationally related, so that no two rules ever activate at the same time). I think (though I haven't checked) that $f$ is ergodic, i.e. if you choose a random initial condition and repeat this process infinitely many times, then eventually you get arbitrarily close to every point in the space. Also, $f$ is measure-preserving, since $f$ maps any subset of the set of possible values of $x$ to an equal-volume set. Therefore, Birkhoff's ergodic theorem says that the proportion of the $\{x,f(x),f^2(x),\ldots\}$ where bucket 1 is the next bucket to be filled, equals the fraction of the possible volume where bucket 1 is the next bucket to be filled.
