/usr/share/gap/lib/unknown.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 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 | #############################################################################
##
#W unknown.gi GAP Library Martin Schönert
##
##
#Y Copyright (C) 1997, Lehrstuhl D für Mathematik, RWTH Aachen, Germany
#Y (C) 1998 School Math and Comp. Sci., University of St Andrews, Scotland
#Y Copyright (C) 2002 The GAP Group
##
## This file implements the arithmetic for unknown values, unknowns for
## short. Unknowns are written as `Unknown(<n>)' where <n> is an integer
## that distingishes different unknowns. Every unknown stands for a fixed,
## well defined, but unknown scalar value, i.e., an unknown integer, an
## unknown rational, or an unknown cyclotomic.
##
## Being unknown is a contagious property. That is to say that the result
## of a scalar operation involving an unknown is also unknown, with the
## exception of multiplication by 0, which is 0. Every scalar operation
## involving an unknown operand is a new unknown, with the exception of
## addition of 0 or multiplication by 1, which is the old unknown.
##
## Note that infinity is not regarded as a well defined scalar value. Thus
## an unknown never stands for infinity. Therefore division by 0 still gives
## an error, not an unknown. Also division by an unknown gives an error,
## because the unknown could stand for 0.
##
#############################################################################
##
#R IsUnknownDefaultRep( <obj> )
##
DeclareRepresentation( "IsUnknownDefaultRep",
IsPositionalObjectRep, [ 1 ] );
#############################################################################
##
#V UnknownsType
##
BindGlobal( "UnknownsType", NewType( CyclotomicsFamily,
IsUnknown and IsUnknownDefaultRep ) );
#############################################################################
##
#M Unknown( <n> ) . . . . . . . . . . . . . . . . . . construct an unknown
##
InstallMethod( Unknown,
"for positive integer",
[ IsPosInt ],
function( n )
if LargestUnknown < n then
LargestUnknown:= n;
fi;
return Objectify( UnknownsType, [ n ] );
end );
#############################################################################
##
#M Unknown( ) . . . . . . . . . . . . . . . . . . . construct a new unknown
##
InstallMethod( Unknown,
"for empty argument",
[],
function()
LargestUnknown:= LargestUnknown + 1;
return Objectify( UnknownsType, [ LargestUnknown ] );
end );
#############################################################################
##
#M PrintObj( <obj> ) . . . . . . . . . . . . . . . . . . . print an unknown
##
## prints the unknown <obj> in the form `Unknown(<n>)'.
##
InstallMethod( PrintObj,
"for unknown in default representation",
[ IsUnknown and IsUnknownDefaultRep ],
function( obj )
Print( "Unknown(", obj![1], ")" );
end );
#############################################################################
##
#M `<x> = <y>' . . . . . . . . . . . . . . . test if two unknowns are equal
##
## is `true' if the two unknowns <x> and <y> are equal,
## and `false' otherwise.
##
## Note that two unknowns with different <n> are assumed to be different.
## I dont like this at all.
##
InstallMethod( \=,
"for unknown and cyclotomic",
[ IsUnknown, IsCyc ],
ReturnFalse );
InstallMethod( \=,
"for cyclotomic and unknown",
[ IsCyc, IsUnknown ],
ReturnFalse );
InstallMethod( \=,
"for two unknowns in default representation",
[ IsUnknown and IsUnknownDefaultRep,
IsUnknown and IsUnknownDefaultRep ],
function( x, y ) return x![1] = y![1]; end );
#############################################################################
##
#M `<x> \< <y>' . . . . . . . . . test if one unknown is less than another
##
## is `true' if the unknown <x> is less than the unknown <y>,
## and `false' otherwise.
##
## Note that two unknowns with different <n> are assumed to be different.
## I don't like this at all.
##
InstallMethod( \<,
"for unknown and cyclotomic",
[ IsUnknown, IsCyc ],
ReturnFalse );
InstallMethod( \<,
"for cyclotomic and unknown",
[ IsCyc, IsUnknown ],
ReturnTrue );
InstallMethod( \<,
"for two unknowns in default representation",
[ IsUnknown and IsUnknownDefaultRep,
IsUnknown and IsUnknownDefaultRep ],
function( x, y ) return x![1] < y![1]; end );
#############################################################################
##
#M `<x> + <y>' . . . . . . . . . . . . . . . . . . . . . sum of two unknowns
##
## is the sum of the two unknowns <x> and <y>.
## Either operand may also be a known scalar value.
##
InstallMethod( \+,
"for unknown and cyclotomic",
[ IsUnknown, IsCyc ],
function( x, y )
if y = 0 then
return x;
else
return Unknown();
fi;
end );
InstallMethod( \+,
"for cyclotomic and unknown",
[ IsCyc, IsUnknown ],
function( x, y )
if x = 0 then
return y;
else
return Unknown();
fi;
end );
InstallMethod( \+,
"for two unknowns",
[ IsUnknown, IsUnknown ],
function( x, y ) return Unknown(); end );
#############################################################################
##
#M `- <x>' . . . . . . . . . . . . . . . . . additive inverse of an unknown
#M `<x> - <y>' . . . . . . . . . . . . . . . . . difference of two unknowns
##
## is the difference of the two unknowns <x> and <y>.
## Either operand may also be a known scalar value.
##
InstallMethod( \-,
"for unknown and cyclotomic",
[ IsUnknown, IsCyc ],
function( x, y )
if y = 0 then
return x;
else
return Unknown();
fi;
end );
InstallMethod( \-,
"for cyclotomic and unknown",
[ IsCyc, IsUnknown ],
function( x, y )
return Unknown();
end );
InstallMethod( \-,
"for two unknowns in default representation",
[ IsUnknown and IsUnknownDefaultRep,
IsUnknown and IsUnknownDefaultRep ],
function( x, y )
if x![1] = y![1] then
return 0;
else
return Unknown();
fi;
end );
InstallMethod( AINV_MUT,
"for an unknown",
[ IsUnknown ],
x -> Unknown() );
#############################################################################
##
#M `<x> \* <y>' . . . . . . . . . . . . . . . . . . product of two unknowns
##
## is the product of the two unknowns <x> and <y>.
## Either operand may also be a known scalar value.
##
InstallMethod( \*,
"for unknown and cyclotomic",
[ IsUnknown, IsCyc ],
function( x, y )
if y = 0 then
return 0;
elif y = 1 then
return x;
else
return Unknown();
fi;
end );
InstallMethod( \*,
"for cyclotomic and unknown",
[ IsCyc, IsUnknown ],
function( x, y )
if x = 0 then
return 0;
elif x = 1 then
return y;
else
return Unknown();
fi;
end );
InstallMethod( \*,
"for two unknowns",
[ IsUnknown, IsUnknown ],
function( x, y )
return Unknown();
end );
#############################################################################
##
#M `<x> / <y>' . . . . . . . . . . . . . . . . . . quotient of two unknowns
##
## is the quotient of the unknown <x> and the scalar <y>.
## <y> must not be zero, and must not be an unknown,
## because the unknown could stand for zero.
##
InstallMethod( \/,
"for unknown and cyclotomic",
[ IsUnknown, IsCyc ],
function( x, y )
if y = 0 then
Error( "divisor must be nonzero" );
elif y = 1 then
return x;
else
return Unknown();
fi;
end );
#############################################################################
##
#M `<x> \^ <y>' . . . . . . . . . . . . . . . . . . . . power of an unknown
##
## is the unknown <x> raised to the integer power <y>.
## If <y> is 0, the result is the integer 1.
## <y> must not be less than 0, because <x> could stand for 0.
##
InstallMethod( \^,
"for unknown and positive integer",
[ IsUnknown, IsPosInt ],
function( x, y )
if y = 1 then
return x;
else
return Unknown();
fi;
end );
InstallMethod( \^,
"for unknown and zero",
[ IsUnknown, IsZeroCyc ],
function( x, zero )
return 1;
end );
#############################################################################
##
#M String( <unknown> ) . . . . . . . . . . . . . . . . . . . for an unknown
##
InstallMethod( String,
"for an unknown in default representation",
[ IsUnknown and IsUnknownDefaultRep ],
unknown -> Concatenation( "Unknown(", String( unknown![1] ), ")" ) );
#############################################################################
##
#E
|