# How to tame the wild MMA?

MMA is a free country. But TOO free sometimes.

Just as an example:

Clear[a]
a[x_] == a[y_] ^:= Round[x] == Round[y]
{a[3] == a[3.01], a[3] == a[4]}


is {True, False}. However,

{a[3] != a[3.01], a[3] != a[4]}


is NOT {False, True}. Of course I have to define for Unequal[]. MMA is flexible, but too much in some situation.

So, I want a "prison". Does the prison such as guidelines or "Eq class" exist ?

ps. sorry for my poor english.

• What do you really need? Is a[x_]:=Round@x or (b : Equal | Unequal)[a[x_], a[y_]] ^:= b[Round[x], Round[y]] satisfying? BTW, what's your first language? – xzczd Oct 31 '15 at 6:22
• @asoldat What do you mean saying that {a[3] != a[3.01], a[3] != a[4]} is NOT {False, True} ? If you don't define the UpSetDelayed for Unequal the result for {a[3] != a[3.01], a[3] != a[4]} is {a[3] != a[3.01], a[3] != a[4]} – Guido Oct 31 '15 at 6:25
• As Guido notes, I would not consider this behavior wild: the behavior was only defined with respect to just one symbol, and Mathematica respected that. Thus, you have at least six relational operators to deal with, as well as Inequality[]. – J. M. will be back soon Oct 31 '15 at 6:33
• eqClass = {Equal, SameQ, Unequal, UnsameQ, Less, LessEqual, Greater, GreaterEqual}; ClearAll[a]; a /: h_[a[x_], a[y_]] /; MemberQ[eqClass, h] := h[Round[x], Round[y]]; {a[3] == a[3.01], a[3] != a[4]} would be a way to go, but there's probably something being lost in translation here? – rm -rf Oct 31 '15 at 6:51
• @R.M. the eqClass which ive wanted. Any other "class" in MMA ? – asoldat Oct 31 '15 at 8:53

a[x_] == a[y_] ^:= Round[x] == Round[y]