22.3 Comparisons of Words

w1 = w2
w1 < w2

The equality operator = evaluates to true if the two words w1 and w2 are equal and to false otherwise. The inequality operator < evaluates to true if the two words w1 and w2 are not equal and to false otherwise.

You can compare words with objects of other types, but they are never equal of course.

    gap> a := AbstractGenerator( "a" );;
    gap> b := AbstractGenerator( "b" );;
    gap> a = b;
    false
    gap> (a^2*b)^5*b^-1 = a^2*b*a^2*b*a^2*b*a^2*b*a^2;
    true 

w1 < w2
w1 <= w2
w1 w2
w1 = w2

The operators <, <=, , and = evaluate to true if the word w1 is less than, less than or equal to, greater than, and greater than or equal to the word w2.

Words are ordered as follows. One word w1 is considered smaller than another word w2 it it is shorted, or, if they have the same length, if it is first in the lexicographical ordering implied by the ordering of the abstract generators. The ordering of abstract generators is as follows. The abstract generators are ordered with respect to the strings that were passed to AbstractGenerator when creating these abstract generators. Each abstract generator g is also smaller than its inverse, but this inverse is smaller than any abstract generator that is larger than g.

Words can also be compared with objects of other types. Integers, rationals, cyclotomics, finite field elements, and permutations are smaller than words, everything else is larger.

    gap> IdWord<a;  a<a^-1;  a^-1<b;  b<b^-1;  b^-1<a^2; a^2<a*b;
    true
    true
    true
    true
    true
    true 

Previous Up Top Next
Index

GAP 3.4.4
April 1997