'Recalculate the ground domain of a polynomial.
Examples
>>> from sympy import Poly
>>> from sympy.abc import x
>>> f = Poly(x**2 + 1, x, domain=\'QQ[y]\')
>>> f
Poly(x**2 + 1, x, domain=\'QQ[y]\')
>>> f.retract()
Poly(x**2 + 1, x, domain=\'ZZ\')
>>> f.retract(field=True)
Poly(x**2 + 1, x, domain=\'QQ\')'

def retract(f, field=None):

    (dom, rep) = construct_domain(f.as_dict(zero=True), field=field, composite=(f.domain.is_Composite or None))
    return f.from_dict(rep, f.gens, domain=dom)
