def signsimp(expr, evaluate=None):
 if (evaluate is None):
  evaluate = global_evaluate[0]
 expr = sympify(expr)
 if ((not isinstance(expr, Expr)) or expr.is_Atom):
  return expr
 e = sub_post(sub_pre(expr))
 if ((not isinstance(e, Expr)) or e.is_Atom):
  return e
 if e.is_Add:
  return e.func(*[signsimp(a) for a in e.args])
 if evaluate:
  e = e.xreplace({m: (- (- m)) for m in e.atoms(Mul) if ((- (- m)) != m)})
 return e

def signsimp ( expr , evaluate = None ) : if ( evaluate is None ) : evaluate = global_evaluate [ 0 ] expr = sympify ( expr ) if ( ( not isinstance ( expr , Expr ) ) or expr . is_Atom ) : return expr e = sub_post ( sub_pre ( expr ) ) if ( ( not isinstance ( e , Expr ) ) or e . is_Atom ) : return e if e . is_Add : return e . func ( * [ signsimp ( a ) for a in e . args ] ) if evaluate : e = e . xreplace ( { m : ( - ( - m ) ) for m in e . atoms ( Mul ) if ( ( - ( - m ) ) != m ) } ) return e
make all add sub-expressions canonical wrt sign .