The ==
operator in programming has two meanings in mathematical logic. The first is equality between elements of the domain =
. The second is double implication ↔
. This is, because you can compare numbers with ==
just like you can compare boolean values with ==
.
In mathematical logic, =
can only compare values of the domain, so a = b
is always a boolean expression, while a
and b
are not. However, if we look at a ↔ b
, then a ↔ b
, a
and b
are boolean expressions. Thus, not a ↔ b
means (not a) ↔ b
and not a = b
means not (a = b)
.
However, since =
and ↔
are represented by the same operator ==
in most programming languages, it is at least very difficult and probably not intuitive to implement different precision rules for ==
when it is used differently.
The reason why it is difficult to implement, is because commonly, the operator precedence is implemented in the parser. When the parser translated the source code into the syntax tree, the operator precedence is already encoded in the tree. The type checking (if any) works with the syntax tree. Thus, the parser does not have access to the type information which implies that it cannot use the type information to apply different precedence rules.