human
Complete this python program:
def TR111(rv):
assistant
#Here is the Python program you requested.

    """Convert f(x)**-i to g(x)**i where either ``i`` is an integer
    or the base is positive and f, g are: tan, cot; sin, csc; or cos, sec.
    Examples
    >>> from sympy.simplify.fu import TR111
    >>> from sympy.abc import x
    >>> from sympy import tan
    >>> TR111(1 - 1/tan(x)**2)
    -cot(x)**2 + 1
    """
    def f(rv):
        if (not (isinstance(rv, Pow) and (rv.base.is_positive or (rv.exp.is_integer and rv.exp.is_negative)))):
            return rv
        if (rv.base.func is tan):
            return (cot(rv.base.args[0]) ** (- rv.exp))
        elif (rv.base.func is sin):
            return (csc(rv.base.args[0]) ** (- rv.exp))
        elif (rv.base.func is cos):
            return (sec(rv.base.args[0]) ** (- rv.exp))
        return rv
    return bottom_up(rv, f)