# How to apply assumptions to pattern matching?

I'm trying to remove terms whose exponents are positive in a polynomial. I tried this one;

Assuming[t > 0, x^t /. {x^a_ /; Positive@a -> 0}]


but the result becomes;

x^t

I want to get 0 instead of this result.

How to do so?

Thank you.

For some reason Mathematica doesn't apply the assumption automatically, but you can enforce it like this:

Assuming[t > 0, x^t /. {x^a_ /; Simplify[Positive@a] -> 0}]


a minimal example:

Assuming[t > 0, t > 0]
(*t>0*)

Assuming[t > 0, Simplify[t > 0]]
(*True*)

• Thank you very much! If it is well-known thing, really sorry for taking your time. – Keyspire Jan 10 at 8:14
• I don't think it's well known and it would be interesting to know why mathematica behaves like this, it doesn't look like a bug. – banone Jan 10 at 8:27
• Regarding automatic application: See the documentation of Assuming: It only affects functions with the Assumptions option, so you need Simplify or similar (Positive doesn't have the option). – Lukas Lang Jan 11 at 10:04