IntegerQ returning False despite setting Assumptions

Why does the following not return True?

Assuming[z ∈ Integers, IntegerQ[z]]
False

I tried this on a fresh session of Mathematica 10.0.2.0.

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.

• 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!
– user9660
Feb 26 '15 at 15:34
• This post is useful, if not closely related. Feb 26 '15 at 17:45

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.

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.

• 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! Feb 26 '15 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.

• Thanks, I now understand the result of the little test. Feb 26 '15 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

True