(expr, assumptions)
Real**Integer              -> Real
        Positive**Real             -> Real
        Real**(Integer/Even)       -> Real if base is nonnegative
        Real**(Integer/Odd)        -> Real
        Imaginary**(Integer/Even)  -> Real
        Imaginary**(Integer/Odd)   -> not Real
        Imaginary**Real            -> ? since Real could be 0 (giving real) or 1 (giving imaginary)
        b**Imaginary               -> Real if log(b) is imaginary and b != 0 and exponent != integer multiple of I*pi/log(b)
        Real**Real                 -> ? e.g. sqrt(-1) is imaginary and sqrt(2) is not
Real**Integer              -> Real
        Positive**Real             -> Real
        Real**(Integer/Even)       -> Real if base is nonnegative
        Real**(Integer/Odd)        -> Real
        Imaginary**(Integer/Even)  -> Real
        Imaginary**(Integer/Odd)   -> not Real
        Imaginary**Real            -> ? since Real could be 0 (giving real) or 1 (giving imaginary)
        b**Imaginary               -> Real if log(b) is imaginary and b != 0 and exponent != integer multiple of I*pi/log(b)
        Real**Real                 -> ? e.g. sqrt(-1) is imaginary and sqrt(2) is not
Real ** Integer - > Real Positive ** Real - > Real Real ** ( Integer / Even ) - > Real if base is nonnegative Real ** ( Integer / Odd ) - > Real Imaginary ** ( Integer / Even ) - > Real Imaginary ** ( Integer / Odd ) - > not Real Imaginary ** Real - > ? since Real could be 0 ( giving real ) or 1 ( giving imaginary ) b ** Imaginary - > Real if log ( b ) is imaginary and b ! = 0 and exponent ! = integer multiple of I * pi / log ( b ) Real ** Real - > ? e . g . sqrt ( - 1 ) is imaginary and sqrt ( 2 ) is not
def Pow(expr, assumptions):
        """
        Real**Integer              -> Real
        Positive**Real             -> Real
        Real**(Integer/Even)       -> Real if base is nonnegative
        Real**(Integer/Odd)        -> Real
        Imaginary**(Integer/Even)  -> Real
        Imaginary**(Integer/Odd)   -> not Real
        Imaginary**Real            -> ? since Real could be 0 (giving real) or 1 (giving imaginary)
        b**Imaginary               -> Real if log(b) is imaginary and b != 0 and exponent != integer multiple of I*pi/log(b)
        Real**Real                 -> ? e.g. sqrt(-1) is imaginary and sqrt(2) is not
        """
        if expr.is_number:
            return AskRealHandler._number(expr, assumptions)

        if expr.base.func == C.exp:
            if ask(Q.imaginary(expr.base.args[0]), assumptions):
                if ask(Q.imaginary(expr.exp), assumptions):
                    return True
            # If the i = (exp's arg)/(I*pi) is an integer or half-integer
            # multiple of I*pi then 2*i will be an integer. In addition,
            # exp(i*I*pi) = (-1)**i so the overall realness of the expr
            # can be determined by replacing exp(i*I*pi) with (-1)**i.
            i = expr.base.args[0]/I/pi
            if ask(Q.integer(2*i), assumptions):
                return ask(Q.real(((-1)**i)**expr.exp), assumptions)
            return

        if ask(Q.imaginary(expr.base), assumptions):
            if ask(Q.integer(expr.exp), assumptions):
                odd = ask(Q.odd(expr.exp), assumptions)
                if odd is not None:
                    return not odd
                return

        if ask(Q.imaginary(expr.exp), assumptions):
            imlog = ask(Q.imaginary(C.log(expr.base)), assumptions)
            if imlog is not None:
                # I**i -> real, log(I) is imag;
                # (2*I)**i -> complex, log(2*I) is not imag
                return imlog

        if ask(Q.real(expr.base), assumptions):
            if ask(Q.real(expr.exp), assumptions):
                if expr.exp.is_Rational and \
                        ask(Q.even(expr.exp.q), assumptions):
                    return ask(Q.positive(expr.base), assumptions)
                elif ask(Q.integer(expr.exp), assumptions):
                    return True
                elif ask(Q.positive(expr.base), assumptions):
                    return True
                elif ask(Q.negative(expr.base), assumptions):
                    return False
def Pow ( expr , assumptions ) : if expr . is_number : return AskRealHandler . _number ( expr , assumptions ) if expr . base . func == C . exp : if ask ( Q . imaginary ( expr . base . args [ 0 ] ) , assumptions ) : if ask ( Q . imaginary ( expr . exp ) , assumptions ) : return True # If the i = (exp's arg)/(I*pi) is an integer or half-integer # multiple of I*pi then 2*i will be an integer. In addition, # exp(i*I*pi) = (-1)**i so the overall realness of the expr # can be determined by replacing exp(i*I*pi) with (-1)**i. i = expr . base . args [ 0 ] / I / pi if ask ( Q . integer ( 2 * i ) , assumptions ) : return ask ( Q . real ( ( ( - 1 ) ** i ) ** expr . exp ) , assumptions ) return if ask ( Q . imaginary ( expr . base ) , assumptions ) : if ask ( Q . integer ( expr . exp ) , assumptions ) : odd = ask ( Q . odd ( expr . exp ) , assumptions ) if odd is not None : return not odd return if ask ( Q . imaginary ( expr . exp ) , assumptions ) : imlog = ask ( Q . imaginary ( C . log ( expr . base ) ) , assumptions ) if imlog is not None : # I**i -> real, log(I) is imag; # (2*I)**i -> complex, log(2*I) is not imag return imlog if ask ( Q . real ( expr . base ) , assumptions ) : if ask ( Q . real ( expr . exp ) , assumptions ) : if expr . exp . is_Rational and ask ( Q . even ( expr . exp . q ) , assumptions ) : return ask ( Q . positive ( expr . base ) , assumptions ) elif ask ( Q . integer ( expr . exp ) , assumptions ) : return True elif ask ( Q . positive ( expr . base ) , assumptions ) : return True elif ask ( Q . negative ( expr . base ) , assumptions ) : return False