/usr/share/axiom-20170501/src/algebra/ALGSC.spad is in axiom-source 20170501-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 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 | )abbrev domain ALGSC AlgebraGivenByStructuralConstants
++ Authors: J. Grabmeier, R. Wisbauer
++ Date Created: 01 March 1991
++ Date Last Updated: 22 January 1992
++ Reference:
++ Gons71 Contributions to Genetic Algebras
++ Reed97 Algebraic Structure of Genetic Inheritance
++ Worz80 Algebra in Genetics
++ Scha66 An Introduction to Nonassociative Algebras
++ Description:
++ AlgebraGivenByStructuralConstants implements finite rank algebras
++ over a commutative ring, given by the structural constants \spad{gamma}
++ with respect to a fixed basis \spad{[a1,..,an]}, where
++ \spad{gamma} is an \spad{n}-vector of n by n matrices
++ \spad{[(gammaijk) for k in 1..rank()]} defined by
++ \spad{ai * aj = gammaij1 * a1 + ... + gammaijn * an}.
++ The symbols for the fixed basis
++ have to be given as a list of symbols.
AlgebraGivenByStructuralConstants(R,n,ls,gamma) : SIG == CODE where
R : Field
n : PositiveInteger
ls : List Symbol
gamma : Vector Matrix R
V ==> Vector
M ==> Matrix
I ==> Integer
NNI ==> NonNegativeInteger
REC ==> Record(particular: Union(V R,"failed"),basis: List V R)
LSMP ==> LinearSystemMatrixPackage(R,V R,V R, M R)
SIG ==> Join(FramedNonAssociativeAlgebra(R), _
LeftModule(SquareMatrix(n,R)) ) with
coerce : Vector R -> %
++ coerce(v) converts a vector to a member of the algebra
++ by forming a linear combination with the basis element.
++ Note: the vector is assumed to have length equal to the
++ dimension of the algebra.
CODE ==> DirectProduct(n,R) add
Rep := DirectProduct(n,R)
x,y : %
dp : DirectProduct(n,R)
v : V R
recip(x) ==
recip(x)$FiniteRankNonAssociativeAlgebra_&(%,R)
(m:SquareMatrix(n,R))*(x:%) ==
apply((m :: Matrix R),x)
coerce v ==
directProduct(v) :: %
structuralConstants() ==
gamma
coordinates(x) ==
vector(entries(x :: Rep)$Rep)$Vector(R)
er1:="coordinates: first argument is not in linear span of second argument"
coordinates(x,b) ==
--not (maxIndex b = n) =>
-- error("coordinates: your 'basis' has not the right length")
m : NonNegativeInteger := (maxIndex b) :: NonNegativeInteger
transitionMatrix : Matrix R := new(n,m,0$R)$Matrix(R)
for i in 1..m repeat
setColumn_!(transitionMatrix,i,coordinates(b.i))
res : REC := solve(transitionMatrix,coordinates(x))$LSMP
if (not every?(zero?$R,first res.basis)) then
error("coordinates: warning your 'basis' is linearly dependent")
(res.particular case "failed") => error(er1)
(res.particular) :: (Vector R)
basis() ==
[unitVector(i::PositiveInteger)::% for i in 1..n]
someBasis() ==
basis()$%
rank() ==
n
elt(x,i) ==
elt(x:Rep,i)$Rep
coerce(x:%):OutputForm ==
zero?(x::Rep)$Rep => (0$R) :: OutputForm
le : List OutputForm := nil
for i in 1..n repeat
coef : R := elt(x::Rep,i)
not zero?(coef)$R =>
((coef) = 1)$R =>
-- sy : OutputForm := elt(ls,i)$(List Symbol) :: OutputForm
le := cons(elt(ls,i)$(List Symbol) :: OutputForm, le)
le := cons(coef :: OutputForm * elt(ls,i)$(List Symbol)_
:: OutputForm, le)
reduce("+",le)
x * y ==
v : Vector R := new(n,0)
for k in 1..n repeat
h : R := 0
for i in 1..n repeat
for j in 1..n repeat
h := h +$R elt(x,i) *$R elt(y,j) *$R elt(gamma.k,i,j )
v.k := h
directProduct v
er2:="algebra satisfies 2*associator(a,b,b)=0 = 2*associator(a,a,b)=0"
alternative?() ==
for i in 1..n repeat
-- expression for check of left alternative is symmetric in i and j:
-- expression for check of right alternative is symmetric in j and k:
for j in 1..i-1 repeat
for k in j..n repeat
-- right check
for r in 1..n repeat
res := 0$R
for l in 1..n repeat
res := res - _
(elt(gamma.l,j,k)+elt(gamma.l,k,j))*elt(gamma.r,i,l)+_
(elt(gamma.l,i,j)*elt(gamma.r,l,k) + elt(gamma.l,i,k)*_
elt(gamma.r,l,j) )
not zero? res =>
messagePrint("algebra is not right alternative")$OutputForm
return false
for j in i..n repeat
for k in 1..j-1 repeat
-- left check
for r in 1..n repeat
res := 0$R
for l in 1..n repeat
res := res + _
(elt(gamma.l,i,j)+elt(gamma.l,j,i))*elt(gamma.r,l,k)-_
(elt(gamma.l,j,k)*elt(gamma.r,i,l) + elt(gamma.l,i,k)*_
elt(gamma.r,j,l) )
not (zero? res) =>
messagePrint("algebra is not left alternative")$OutputForm
return false
for k in j..n repeat
-- left check
for r in 1..n repeat
res := 0$R
for l in 1..n repeat
res := res + _
(elt(gamma.l,i,j)+elt(gamma.l,j,i))*elt(gamma.r,l,k)-_
(elt(gamma.l,j,k)*elt(gamma.r,i,l) + elt(gamma.l,i,k)*_
elt(gamma.r,j,l) )
not (zero? res) =>
messagePrint("algebra is not left alternative")$OutputForm
return false
-- right check
for r in 1..n repeat
res := 0$R
for l in 1..n repeat
res := res - _
(elt(gamma.l,j,k)+elt(gamma.l,k,j))*elt(gamma.r,i,l)+_
(elt(gamma.l,i,j)*elt(gamma.r,l,k) + elt(gamma.l,i,k)*_
elt(gamma.r,l,j) )
not (zero? res) =>
messagePrint("algebra is not right alternative")$OutputForm
return false
messagePrint(er2)$OutputForm
true
associative?() ==
for i in 1..n repeat
for j in 1..n repeat
for k in 1..n repeat
for r in 1..n repeat
res := 0$R
for l in 1..n repeat
res := res + elt(gamma.l,i,j)*elt(gamma.r,l,k)-_
elt(gamma.l,j,k)*elt(gamma.r,i,l)
not (zero? res) =>
messagePrint("algebra is not associative")$OutputForm
return false
messagePrint("algebra is associative")$OutputForm
true
antiAssociative?() ==
for i in 1..n repeat
for j in 1..n repeat
for k in 1..n repeat
for r in 1..n repeat
res := 0$R
for l in 1..n repeat
res := res + elt(gamma.l,i,j)*elt(gamma.r,l,k)+_
elt(gamma.l,j,k)*elt(gamma.r,i,l)
not (zero? res) =>
messagePrint("algebra is not anti-associative")$OutputForm
return false
messagePrint("algebra is anti-associative")$OutputForm
true
commutative?() ==
for i in 1..n repeat
for j in (i+1)..n repeat
for k in 1..n repeat
not ( elt(gamma.k,i,j)=elt(gamma.k,j,i) ) =>
messagePrint("algebra is not commutative")$OutputForm
return false
messagePrint("algebra is commutative")$OutputForm
true
antiCommutative?() ==
for i in 1..n repeat
for j in i..n repeat
for k in 1..n repeat
not zero? (i=j => elt(gamma.k,i,i); _
elt(gamma.k,i,j)+elt(gamma.k,j,i) ) =>
messagePrint("algebra is not anti-commutative")$OutputForm
return false
messagePrint("algebra is anti-commutative")$OutputForm
true
leftAlternative?() ==
for i in 1..n repeat
-- expression is symmetric in i and j:
for j in i..n repeat
for k in 1..n repeat
for r in 1..n repeat
res := 0$R
for l in 1..n repeat
res := res+(elt(gamma.l,i,j)+elt(gamma.l,j,i))*elt(gamma.r,l,k)-_
(elt(gamma.l,j,k)*elt(gamma.r,i,l) + _
elt(gamma.l,i,k)*elt(gamma.r,j,l) )
not (zero? res) =>
messagePrint("algebra is not left alternative")$OutputForm
return false
messagePrint("algebra is left alternative")$OutputForm
true
rightAlternative?() ==
for i in 1..n repeat
for j in 1..n repeat
-- expression is symmetric in j and k:
for k in j..n repeat
for r in 1..n repeat
res := 0$R
for l in 1..n repeat
res := res-(elt(gamma.l,j,k)+elt(gamma.l,k,j))*elt(gamma.r,i,l)+_
(elt(gamma.l,i,j)*elt(gamma.r,l,k) + _
elt(gamma.l,i,k)*elt(gamma.r,l,j) )
not (zero? res) =>
messagePrint("algebra is not right alternative")$OutputForm
return false
messagePrint("algebra is right alternative")$OutputForm
true
flexible?() ==
for i in 1..n repeat
for j in 1..n repeat
-- expression is symmetric in i and k:
for k in i..n repeat
for r in 1..n repeat
res := 0$R
for l in 1..n repeat
res := res + elt(gamma.l,i,j)*elt(gamma.r,l,k)-_
elt(gamma.l,j,k)*elt(gamma.r,i,l)+_
elt(gamma.l,k,j)*elt(gamma.r,l,i)-_
elt(gamma.l,j,i)*elt(gamma.r,k,l)
not (zero? res) =>
messagePrint("algebra is not flexible")$OutputForm
return false
messagePrint("algebra is flexible")$OutputForm
true
lieAdmissible?() ==
for i in 1..n repeat
for j in 1..n repeat
for k in 1..n repeat
for r in 1..n repeat
res := 0$R
for l in 1..n repeat
res := res_
+ (elt(gamma.l,i,j)-elt(gamma.l,j,i))*_
(elt(gamma.r,l,k)-elt(gamma.r,k,l)) _
+ (elt(gamma.l,j,k)-elt(gamma.l,k,j))*_
(elt(gamma.r,l,i)-elt(gamma.r,i,l)) _
+ (elt(gamma.l,k,i)-elt(gamma.l,i,k))*_
(elt(gamma.r,l,j)-elt(gamma.r,j,l))
not (zero? res) =>
messagePrint("algebra is not Lie admissible")$OutputForm
return false
messagePrint("algebra is Lie admissible")$OutputForm
true
er3:="this algebra is not Jordan admissible, _
as 2 is not invertible in the ground ring"
jordanAdmissible?() ==
recip(2 * 1$R) case "failed" =>
messagePrint(er3)$OutputForm
false
for i in 1..n repeat
for j in 1..n repeat
for k in 1..n repeat
for w in 1..n repeat
for t in 1..n repeat
res := 0$R
for l in 1..n repeat
for r in 1..n repeat
res := res_
+ (elt(gamma.l,i,j)+elt(gamma.l,j,i))_
* (elt(gamma.r,w,k)+elt(gamma.r,k,w))_
* (elt(gamma.t,l,r)+elt(gamma.t,r,l))_
- (elt(gamma.r,w,k)+elt(gamma.r,k,w))_
* (elt(gamma.l,j,r)+elt(gamma.l,r,j))_
* (elt(gamma.t,i,l)+elt(gamma.t,l,i))_
+ (elt(gamma.l,w,j)+elt(gamma.l,j,w))_
* (elt(gamma.r,k,i)+elt(gamma.r,i,k))_
* (elt(gamma.t,l,r)+elt(gamma.t,r,l))_
- (elt(gamma.r,k,i)+elt(gamma.r,k,i))_
* (elt(gamma.l,j,r)+elt(gamma.l,r,j))_
* (elt(gamma.t,w,l)+elt(gamma.t,l,w))_
+ (elt(gamma.l,k,j)+elt(gamma.l,j,k))_
* (elt(gamma.r,i,w)+elt(gamma.r,w,i))_
* (elt(gamma.t,l,r)+elt(gamma.t,r,l))_
- (elt(gamma.r,i,w)+elt(gamma.r,w,i))_
* (elt(gamma.l,j,r)+elt(gamma.l,r,j))_
* (elt(gamma.t,k,l)+elt(gamma.t,l,k))
not (zero? res) =>
messagePrint("algebra is not Jordan admissible")$OutputForm
return false
messagePrint("algebra is Jordan admissible")$OutputForm
true
er4:="this is not a Jordan algebra, _
as 2 is not invertible in the ground ring"
jordanAlgebra?() ==
recip(2 * 1$R) case "failed" =>
messagePrint(er4)$OutputForm
false
not commutative?() =>
messagePrint("this is not a Jordan algebra")$OutputForm
false
for i in 1..n repeat
for j in 1..n repeat
for k in 1..n repeat
for l in 1..n repeat
for t in 1..n repeat
res := 0$R
for r in 1..n repeat
for s in 1..n repeat
res := res + _
elt(gamma.r,i,j)*elt(gamma.s,l,k)*elt(gamma.t,r,s) - _
elt(gamma.r,l,k)*elt(gamma.s,j,r)*elt(gamma.t,i,s) + _
elt(gamma.r,l,j)*elt(gamma.s,k,k)*elt(gamma.t,r,s) - _
elt(gamma.r,k,i)*elt(gamma.s,j,r)*elt(gamma.t,l,s) + _
elt(gamma.r,k,j)*elt(gamma.s,i,k)*elt(gamma.t,r,s) - _
elt(gamma.r,i,l)*elt(gamma.s,j,r)*elt(gamma.t,k,s)
not zero? res =>
messagePrint("this is not a Jordan algebra")$OutputForm
return false
messagePrint("this is a Jordan algebra")$OutputForm
true
jacobiIdentity?() ==
for i in 1..n repeat
for j in 1..n repeat
for k in 1..n repeat
for r in 1..n repeat
res := 0$R
for s in 1..n repeat
res := res + elt(gamma.r,i,j)*elt(gamma.s,j,k) +_
elt(gamma.r,j,k)*elt(gamma.s,k,i) +_
elt(gamma.r,k,i)*elt(gamma.s,i,j)
not zero? res =>
messagePrint("Jacobi identity does not hold")$OutputForm
return false
messagePrint("Jacobi identity holds")$OutputForm
true
|