/usr/share/gap/lib/adjoin.gi is in gap-libs 4r6p5-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 | #############################################################################
#W adjoin.gi GAP library Steve Linton
##
##
## This file contains the declarations for functions pertaining to
## adjoining an identity element to a semigroup.
##
###########################################################################
##
#M AdjoinedIdentityFamily( <fam> )
##
InstallMethod(AdjoinedIdentityFamily, [IsFamily],
function(fam)
local afam;
afam := NewFamily(Concatenation("AdjoinedIdentityFamily(",fam!.NAME,")"),
IsMonoidByAdjoiningIdentityElt);
SetUnderlyingSemigroupFamily(afam, fam);
return afam;
end);
###########################################################################
##
#M AdjoinedIdentityDefaultType( <fam> )
##
InstallMethod(AdjoinedIdentityDefaultType, [IsFamily],
function(fam)
return NewType(fam, IsMonoidByAdjoiningIdentityEltRep and
IsMonoidByAdjoiningIdentityElt);
end);
###########################################################################
##
#A MonoidByAdjoiningIdentityElt( <elt> )
##
## the result of this function is the corresponding element in the category
## MonoidByAdjoiningIdentityElt with IsOne set to false.
##
InstallMethod( MonoidByAdjoiningIdentityElt, [IsMultiplicativeElement and IsAssociativeElement],
function(se)
local fam, l;
fam := FamilyObj(se);
l := [ se ];
Objectify(AdjoinedIdentityDefaultType(AdjoinedIdentityFamily(fam)),l);
SetIsOne(l,false);
return l;
end);
###########################################################################
##
#M <elt1> \* <elt2>
##
## returns <elt2> if <elt1> represents the identity, <elt1> if <elt2>
## represents the identity, and otherwise returns the value of
## MonoidByAdjoiningIdentityElt for product of the underlying
## elements.
##
InstallMethod(\*, IsIdenticalObj,
[IsMonoidByAdjoiningIdentityElt, IsMonoidByAdjoiningIdentityElt],
function(me1,me2)
if me1![1] = fail then
return me2;
elif me2![1] = fail then
return me1;
else
return MonoidByAdjoiningIdentityElt(me1![1] * me2![1]);
fi;
end);
###########################################################################
##
#M <elt1> \< <elt2>
##
## compares underlying elements if they exist, and considers the representative
## of the identity to be the least element otherwise.
##
InstallMethod(\<, IsIdenticalObj,
[IsMonoidByAdjoiningIdentityElt, IsMonoidByAdjoiningIdentityElt],
function(me1,me2)
if me1![1] = fail then
return me2![1] <> fail;
elif me2![1] = fail then
return false;
else
return me1![1] < me2![1];
fi;
end);
###########################################################################
##
#M <elt1> \= <elt2>
##
## returns true if both elements represent the identity, false if one does
## and the other doesn't, otherwise compares underlying elements.
##
InstallMethod(\=, IsIdenticalObj,
[IsMonoidByAdjoiningIdentityElt, IsMonoidByAdjoiningIdentityElt],
function(me1,me2)
if me1![1] = fail then
return me2![1] = fail;
elif me2![1] = fail then
return false;
else
return me1![1] = me2![1];
fi;
end);
###########################################################################
##
#M One( <elt> )
##
## returns the One of the element <elt>.
##
InstallMethod(One, [IsMonoidByAdjoiningIdentityElt],
function(me)
local l;
l := [ fail];
Objectify(AdjoinedIdentityDefaultType(FamilyObj(me)),l);
SetIsOne(l, true);
return l;
end);
###########################################################################
##
#M MonoidByAdjoiningIdentity( <semigroup> )
##
## returns the monoid obtained from <semigroup> by adjoining an identity.
##
InstallMethod(MonoidByAdjoiningIdentity, [IsSemigroup and HasGeneratorsOfSemigroup],
function( s )
local m;
m:=Monoid(List(GeneratorsOfSemigroup(s), MonoidByAdjoiningIdentityElt));
SetUnderlyingSemigroupOfMonoidByAdjoiningIdentity(m, s);
return m;
end);
###########################################################################
##
#M UnderlyingSemigroupElementOfMonoidByAdjoiningIdentityElt( <elt> )
##
## returns the underlying element of the MonoidByAdjoiningIdentityElt <elt>.
##
InstallMethod(UnderlyingSemigroupElementOfMonoidByAdjoiningIdentityElt,
[IsMonoidByAdjoiningIdentityElt],
x->x![1]);
InstallMethod(PrintObj, [IsMonoidByAdjoiningIdentityElt],
function(me)
if me![1] = fail then
Print("<adjoined identity>");
return;
fi;
Print("MonoidByAdjoiningIdentityElt(");
Print(me![1]);
Print(")");
end);
InstallMethod(ViewObj, [IsMonoidByAdjoiningIdentityElt],
function(me)
if me![1] = fail then
Print("ONE");
return;
fi;
ViewObj(me![1]);
end);
#############################################################################
##
#E adjoin.gi . . . . . . . . . . . . . . . . . . . . . . . . . . . ends
|