Check that an expression is in the correct form g

Does anyone have a way to check that an expression is in the correct form? For example, when students are given a^m*a^n I want them to enter a^(m+n), I know how to do this for expressions containing numbers by using countNumberUsage(), but I am not sure what to do if the expression only contains variables since the student b