Sums of finite sets, orbits of commutative semigroups, and Hilbert functions