'Make the ground domain exact.
Examples
>>> from sympy import Poly, RR
>>> from sympy.abc import x
>>> Poly(x**2 + 1.0, x, domain=RR).to_exact()
Poly(x**2 + 1, x, domain=\'QQ\')'

def to_exact(f):

    if hasattr(f.rep, 'to_exact'):
        result = f.rep.to_exact()
    else:
        raise OperationNotSupported(f, 'to_exact')
    return f.per(result)
