Macaulay2 » Documentation
Packages » Macaulay2Doc > The Macaulay2 language > operators > Thing === Thing
next | previous | forward | backward | up | index | toc

Thing === Thing -- strict equality

Synopsis

Description

Strictly equal expressions have the same type, so 0===0. and 0===0/1 are false; the three types involved here are ZZ, RR, and QQ.

If x and y are isMutable then they are strictly equal only if they are identical (i.e., at the same address in memory). For details about why strict equality cannot depend on the contents of mutable hash tables, see hashing. On the other hand, if x and y are non-mutable, then they are strictly equal if and only if all their contents are strictly equal.

i1 : {1,2,3} === {1,2,3}

o1 = true
i2 : {1,2,3} === {2,1,3}

o2 = false

For some types, such as ring elements and matrices, strict equality is the same as mathematical equality. This tends to be the case for objects for which not much computation is not required to test equality. For certain other types, such as Ideal or Module, where extensive computations may be required, the operator == implements the desired comparison.

i3 : R = QQ[a..d];
i4 : a^2+b === b+a^2

o4 = true
i5 : ideal(a^2+b,c*d) === ideal(b+a^2,c*d+b+a^2)

o5 = false
i6 : matrix{{a,b,c}} === matrix{{a,b,c}}

o6 = true
i7 : matrix{{a,b,c}} === transpose matrix{{a},{b},{c}}

o7 = false

As it happens, polynomial rings are mutable objects, and new ones are easily created, which are distinct from each other. For example, the rings A and B below are not strictly equal.

i8 : A = QQ[x]; B = QQ[x];
i10 : A === B

o10 = false

See also

Ways to use this method: