In the last section we mentioned that every object is given a certain
place in memory by the GAP storage manager (although that place may
change in the course of a GAP session). In this sense, objects at
different places in memory are never equal, and if the object pointed to
by the variable a (to be more precise, the variable with identifier
a) is equal to the object pointed to by the variable b, then we
should better say that they are not only equal but identical. GAP
provides the function IsIdenticalObj to test whether this is the case.
gap> a:= (1,2);; IsIdenticalObj( a, a ); true gap> b:= (1,2);; IsIdenticalObj( a, b ); false gap> b:= a;; IsIdenticalObj( a, b ); true
As the above example indicates, GAP
objects a and b can be unequal although they are equal from a
mathematical point of view, i.e., although we should have a = b. It
may be that the objects a and b are stored in different places in
memory, or it may be that we have an equivalence relation defined on the
set of objects under which a and b belong to the same equivalence
class. For example, if a = x3 and b = x-5 are words in
the finitely presented group áx\mid x2 = 1ñ, we would have
a = b in that group.
GAP uses the equality operator = to denote such a mathematical
equality, not the identity of objects. Hence we often have a = b
although IsIdenticalObj( a, b ) = false. The operator = defines
an equivalence relation on the set of all GAP objects, and we call the
corresponding equivalence classes elements. Phrasing it differently,
the same element may be represented by various GAP objects.
Non-trivial examples of elements that are represented by different objects (objects that really look different, not ones that are merely stored in different memory places) will occur only when we will be considering composite objects such as lists or domains.
[Top] [Previous] [Up] [Next] [Index]
GAP 4 manual