finding constantness of a term
You might want to take a look at the compiler literature for some ideas.  What you're describing is akin to a well-known compiler optimization (virtually any modern compiler worth its salt will do it) called constant folding.  Of course, constant folding goes further in not just identifying constant expressions, but replacing them by their value.

In particular, compilers use a dataflow analysis to identify such constant expressions.  Any good compiler textbook will discuss this.