build functions for multivariate polynomials
prime-p finds the next prime number