which is what I would expect, but the command
Why is Mathematica agnostic as to whether 1 is equal to Null ? Surely it is not ?
SameQ) tests structural equality and is meant mainly for programming uses. Like nearly all functions named as
...Q, it evaluates immediately to either
== both represents and tests mathematical equality, and is meant for symbolic algebra use.
== is used with a symbol (or expression containing symbols) on either side, it will not evaluate. It stays unevaluated and it can be used to represent a mathematical statement. This is how we write equations in Mathematica, e.g.
x^2 - 2 == 0.
Null has no meaning in symbolic algebra uses so here it is just treated as a symbol, which it is. Thus
1 == Null stays unevaluated the same way
1 == x does.
Mathematica is loosely typed: everything is an expression. You may put just about anything on either side of
==. The nature of the language does not make it practical or worthwhile for functions to try to give a special treatment for each kind of object. Since
Null has no special meaning or use in symbolic algebra, it receives no special treatment from
Also consider that Mathematica will take things like
Solve[Null^2 == 2, Null] with no complaint.