Why does the following not return True?

Assuming[z ∈ Integers, IntegerQ[z]]

I tried this on a fresh session of Mathematica

I understand that IntegerQ does return False if it cannot determine whether the argument is an integer, but in the above case it should be possible to this. I have a vague idea that this questions is similar to this one posted already, however the workaround of using Simplify proposed there does not work in my case.

In case you want to have more details about my actual problem, I'm trying to define a function taking integer arguments. I want to define separate branches of the function, depending on whether the argument is even or odd. Now, using EvenQ and OddQ as a constraint on the function definition runs into the same problem that I describe above.

  • $\begingroup$ Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Read the faq! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! $\endgroup$
    – user9660
    Commented Feb 26, 2015 at 15:34
  • $\begingroup$ This post is useful, if not closely related. $\endgroup$ Commented Feb 26, 2015 at 17:45

3 Answers 3


Basically IntegerQ is for determining whether the object inside it is an integer, not whether it represents an integer. Since z is a Symbol, we get False.

As for your function, I'm assuming you're using some variant of If[EvenQ[z], ___]. As you said, this won't work because EvenQ will always return False on a symbol since z does not have head Integer.

Try this instead:

f[n_ ? OddQ] := Row[{n, " is odd"}]
f[n_ ? EvenQ] := Row[{n, " is even"}]

If your argument is not an integer, the function will be held unevaluated until it gets explicitly replaced by an integer.

  • $\begingroup$ Thanks! You were exactly right with your guess of what I was trying to achieve. Thanks very much for telling me the proper way of how to define such functions! $\endgroup$ Commented Feb 26, 2015 at 16:03

According to the documentation (ref/IntegerQ):

IntegerQ[expr] returns False unless expr is manifestly an integer (i.e. has head Integer). [emph added]

Evidently the assumption does not make z an actual integer, that is, an expression whose head is Integer.

  • $\begingroup$ Thanks, I now understand the result of the little test. $\endgroup$ Commented Feb 26, 2015 at 16:03

Maybe obvious but if you want to test if $z$ represents an integer you can use:

Assuming[z \[Element] Integers, Simplify[z \[Element] Integers]]

This gives


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.