Guard against extracting a gcd for symbolic powers.

Fixes issue 4032: trigsimp() TypeError: symbolic boolean expression has no truth value
http://code.google.com/p/sympy/issues/detail?id=4032