# Ticket #54: freegb.lib.diff3

File freegb.lib.diff3, 20.2 KB (added by , 14 years ago) |
---|

Line | |
---|---|

1 | ====3 |

2 | 1:2c |

3 | 2:2c |

4 | version="$Id: freegb.lib,v 1.12 2008/10/06 17:04:27 Singular Exp $"; |

5 | 3:2c |

6 | version="$Id: freegb.lib,v 1.16 2009/02/13 21:37:20 levandov Exp $"; |

7 | ====3 |

8 | 1:5c |

9 | 2:5c |

10 | LIBRARY: freegb.lib Twosided Noncommutative Groebner bases in Free Algebras |

11 | 3:5c |

12 | LIBRARY: freegb.lib Twosided Noncommutative Groebner bases in Free Algebras via Letterplace |

13 | ==== |

14 | 1:8,10c |

15 | PROCEDURES: |

16 | freegbRing(int d); creates a ring with d blocks of shifted original variables |

17 | freegbasis(list L, int n); compute two-sided Groebner basis of ideal, encoded via L, up to degree n |

18 | 2:8,20c |

19 | BACKGROUND: |

20 | TODO: WRITE DOWN SOME THEORY BEHIND (DIVISIBILITY, ORDERING ON FREE ASSOC. ALG., GB) |

21 | TODO: ADD REFERENCES |

22 | TODO: EXPLAIN YOUR ASSUMPTIONS/IMPLICITE AGREEMENTS/INPUT, OUTPUT FORMATS ETC. |

23 | TODO: BAD NAMES, SEE 3.9.1 Procedures in a library, 5^th rule. PLEASE RENAME! |

24 | |

25 | |

26 | MAIN PROCEDURES: |

27 | |

28 | freegbRing(int d); creates a ring with d blocks of shifted original variables |

29 | freegbasis(list L, int n); computes two-sided GB of an ideal up to degree n |

30 | |

31 | AUXILIARY PROCEDURES: |

32 | 3:8,14c |

33 | THEORY: See chapter 'Letterplace' in the Singular Manual. |

34 | |

35 | PROCEDURES: |

36 | freegbRing(d); creates a ring with d blocks of shifted original variables |

37 | freegbasis(L, int n); compute two-sided Groebner basis of ideal, encoded via L, up to degree n |

38 | |

39 | AUXILIARY PROCEDURES: |

40 | ==== |

41 | 1:12c |

42 | CONVERSION ROUTINES: |

43 | 2:22,30c |

44 | lp2lstr(ideal K, def save); converts letter-place ideal to a list of modules |

45 | lst2str(list L[,int n]); converts a list of modules into polys in free alg. |

46 | mod2str(module M[,int n]); converts a module into a polynomial in free algebra |

47 | vct2str(module M[,int n]); converts a vector into a word in free algebra |

48 | " |

49 | |

50 | // TODO: LOTS OF GLOBAL UNLISTED PROCS WITHOUT HELP/EXAMPLES... -> |

51 | // -> MAKE THEM STATIC OR DOCUMENT THEM! |

52 | // TODO: AT LEAST SOME (E.G. Serre MUST BE LISTED IN THE HEADER) |

53 | 3:16,24c |

54 | lpMult(f,g); letterplace multiplication of letterplace polynomials |

55 | lp2lstr(K, s); convert letter-place ideal to a list of modules |

56 | lst2str(L[, n]); convert a list (of modules) into polynomials in free algebra |

57 | mod2str(M[, n]); convert a module into a polynomial in free algebra |

58 | vct2str(M[, n]); convert a vector into a word in free algebra |

59 | Liebr(a,b[, N]); compute Lie bracket ab-ba of two letterplace polynomials |

60 | Serre(A,z); compute the ideal of Serre's relations associated to a generalized Cartan matrix A |

61 | isVar(p); check whether p is a power of a single variable |

62 | adem(i,j); compute the ideal of Adem relations for i<2j in char 0 |

63 | ==== |

64 | 1:14,18c |

65 | lp2lstr(ideal K, def save): converts letter-place ideal to a list of modules |

66 | lst2str(list L[,int n]); convert a list (of modules) into polynomials in free algebra |

67 | mod2str(module M[,int n]); convert a module into a polynomial in free algebra |

68 | vct2str(module M[,int n]); convert a vector into a word in free algebra |

69 | " |

70 | 2:32c |

71 | // TODO: MOVE THE FOLLOWING TO THE ABOVE BACKGROUND... |

72 | 3:26,27c |

73 | SEE ALSO: Letterplace |

74 | " |

75 | ====2 |

76 | 1:26a |

77 | 3:35a |

78 | 2:41,44c |

79 | |

80 | |

81 | |

82 | |

83 | ====3 |

84 | 1:29a |

85 | 2:47a |

86 | 3:39,53c |

87 | proc testfreegblib() |

88 | { |

89 | example freegbRing; |

90 | example freegbasis; |

91 | "AUXILIARY PROCEDURES: "; |

92 | example lpMult; |

93 | example lp2lstr; |

94 | example lst2str; |

95 | example mod2str; |

96 | example vct2str; |

97 | example Liebr; |

98 | example Serre; |

99 | example isVar; |

100 | } |

101 | |

102 | ====3 |

103 | 1:33c |

104 | 2:51c |

105 | proc lshift(module M, int s, string varing, def lpring) |

106 | 3:57c |

107 | static proc lshift(module M, int s, string varing, def lpring) |

108 | ====3 |

109 | 1:78c |

110 | 2:96c |

111 | proc skip0(vector v) |

112 | 3:102c |

113 | static proc skip0(vector v) |

114 | ====2 |

115 | 1:100a |

116 | 3:124a |

117 | 2:119,122c |

118 | |

119 | // TODO: ANY ASSUMPTIONS ON THE BASERING? |

120 | // TODO: EXPLAIN WHICH FREE ALGEBRA IS MEANT? |

121 | |

122 | ====2 |

123 | 1:103,104c |

124 | 3:127,128c |

125 | RETURN: list (of strings) |

126 | PURPOSE: convert a list (of modules) into polynomials in free algebra |

127 | 2:125,127c |

128 | RETURN: list of strings |

129 | PURPOSE: converts a list of modules into a list of strings representing |

130 | corresponding module as an element in the free algebra |

131 | ====2 |

132 | 1:106c |

133 | 3:130c |

134 | NOTE: if an optional integer is not 0, stars signs are used in multiplication |

135 | 2:129c |

136 | NOTE: if an optional integer is not 0, stars signs are used in multiplication |

137 | ====2 |

138 | 1:115c |

139 | 3:139c |

140 | if (#[1]) |

141 | 2:138c |

142 | if (typeof(#[1]) == "int") |

143 | ====2 |

144 | 1:121c |

145 | 3:145c |

146 | int s = size(L); |

147 | 2:144c |

148 | int s = size(L); |

149 | ====2 |

150 | 1:131,132c |

151 | 3:155,156c |

152 | "module or matrix expected in the list"; |

153 | return(N); |

154 | 2:154,156c |

155 | ERROR("module or matrix expected in the list"); |

156 | brake; |

157 | // return(N); |

158 | ====2 |

159 | 1:148a |

160 | 3:172a |

161 | 2:173,175c |

162 | // TODO: ANY ASSUMPTIONS ON THE BASERING/INPUT!? |

163 | // TODO: EXPLAIN WHICH FREE ALGEBRA IS MEANT? |

164 | |

165 | ====2 |

166 | 1:152c |

167 | 3:176c |

168 | PURPOSE: convert a module into a polynomial in free algebra |

169 | 2:179,180c |

170 | PURPOSE: Converts the module M into a string representing M |

171 | as an element in the free algebra |

172 | ====2 |

173 | 1:163c |

174 | 3:187c |

175 | if (#[1]) |

176 | 2:191c |

177 | if (typeof(#[1]) == "int") |

178 | ====2 |

179 | 1:196a |

180 | 3:220a |

181 | 2:225,231c |

182 | // TODO: WHAT ABOUT ZERO? |

183 | M = 0; |

184 | mod2str(M); // TODO: FIX BUG: MUST BE JUST A ZERO! |

185 | M = [0], [0], [1], [0, x]; |

186 | mod2str(M); // TODO: FIX THIS BUGS! |

187 | M = [1, x, y, z], [0, x], [2, y], [0]; |

188 | mod2str(M); |

189 | ====2 |

190 | 1:198a |

191 | 3:222a |

192 | 2:234,236c |

193 | // TODO: ANY ASSUMPTIONS ON THE BASERING/INPUT!? |

194 | // TODO: EXPLAIN WHICH FREE ALGEBRA IS MEANT? |

195 | |

196 | ====2 |

197 | 1:202c |

198 | 3:226c |

199 | PURPOSE: convert a vector into a word in free algebra |

200 | 2:240c |

201 | PURPOSE: Converts a vector into a string representing a word in the free alg. |

202 | ====2 |

203 | 1:211c |

204 | 3:235c |

205 | if (#[1]) |

206 | 2:249c |

207 | if (typeof(#[1]) == "int") |

208 | ====3 |

209 | 1:226c |

210 | 2:264c |

211 | p = IsVar(v[i+1]); |

212 | 3:250c |

213 | p = isVar(v[i+1]); |

214 | ====2 |

215 | 1:287a |

216 | 3:311a |

217 | 2:326,337c |

218 | // TODO: WHAT ABOUT ZERO? |

219 | vector M = 0; |

220 | vct2str(M); |

221 | M = [0]; |

222 | vct2str(M); |

223 | M = [0, x, y3, z(1)]; |

224 | vct2str(M,1); // TODO: FIX BUG: MUST BE ZERO! |

225 | M = [1, x, 0, z(1)]; |

226 | vct2str(M,1); |

227 | M = [1, 0, z(1), 0, 0, x*y3, 0, 666]; |

228 | vct2str(M,1); // TODO: FIX BUG: WHAT IS THIS??? |

229 | |

230 | ====3 |

231 | 1:290c |

232 | 2:340c |

233 | proc IsVar(poly p) |

234 | 3:314,320c |

235 | proc isVar(poly p) |

236 | "USAGE: isVar(p); poly p |

237 | RETURN: int |

238 | PURPOSE: checks whether p is a power of a single variable from the basering. |

239 | @* Returns the exponent or 0 is p is not a power of a single variable. |

240 | EXAMPLE: example isVar; shows examples |

241 | " |

242 | ====3 |

243 | 1:319c |

244 | 2:369c |

245 | IsVar(f); |

246 | 3:349c |

247 | isVar(f); |

248 | ====3 |

249 | 1:321c |

250 | 2:371c |

251 | IsVar(g); |

252 | 3:351c |

253 | isVar(g); |

254 | ====3 |

255 | 1:323c |

256 | 2:373c |

257 | IsVar(h); |

258 | 3:353c |

259 | isVar(h); |

260 | ====3 |

261 | 1:325c |

262 | 2:375c |

263 | IsVar(i); |

264 | 3:355c |

265 | isVar(i); |

266 | ====3 |

267 | 1:330c |

268 | 2:380c |

269 | proc id2words(ideal I, int d) |

270 | 3:360c |

271 | static proc id2words(ideal I, int d) |

272 | ====3 |

273 | 1:373c |

274 | 2:423c |

275 | proc mono2word(poly p, int d) |

276 | 3:403c |

277 | static proc mono2word(poly p, int d) |

278 | ====2 |

279 | 1:392a |

280 | 3:422a |

281 | 2:443,447c |

282 | |

283 | // TODO: BAD NAME -> RENAME! |

284 | // TODO: NO ASSUMPTIONS? WHAT ABOUT NON-COMM. INPUT RING? NON-HOMOG. INPUT? |

285 | // TODO: ADD STEP-BY-STEP COMMENTS. |

286 | |

287 | ====2 |

288 | 1:395,397c |

289 | 3:425,427c |

290 | RETURN: ring |

291 | PURPOSE: compute the two-sided Groebner basis of an ideal, encoded by L in |

292 | the free associative algebra, up to degree d |

293 | 2:450,461c |

294 | RETURN: ring, |

295 | TODO: EXPLAIN OUTPUT FORMAT |

296 | PURPOSE: compute the two-sided Groebner basis of an ideal, encoded by L |

297 | (TODO: EXPLAIN FORMAT OF L) |

298 | in the free associative algebra, |

299 | (TODO: WHICH free associative algebra? SYMBOLS? GROUND FIELD?) |

300 | up to degree d |

301 | BACKGROUND: |

302 | TODO: EXPLAIN ALGORITHM, GIVE REFERENCES! |

303 | TODO: WHAT ABOUT TERMINATION? |

304 | DISPLAY: |

305 | TODO: EXPLAIN! |

306 | ====2 |

307 | 1:424a |

308 | 3:454a |

309 | 2:489,493c |

310 | |

311 | // TODO: THE FOLLOWING SEEMS TO BE THE CONTENT OF 'freegbRing'! |

312 | // AND THUS IS OVERSIMPLIFIED: WHAT IF VARIABLES/PARAMETERS HAVE BRACKETS? |

313 | // SEE EXAMPLE FOR 'freegbRing'! |

314 | |

315 | ====2 |

316 | 1:477,478c |

317 | 3:507,508c |

318 | def @R = ring(L); |

319 | setring @R; |

320 | 2:546,553c |

321 | def @R = ring(L); |

322 | |

323 | // HERE END 'freegbRing'! ;-) |

324 | |

325 | |

326 | // TODO: THE FOLLOWING CONVERSION DESERVES TO BE AN AUXILIARY PROCEDURE! |

327 | |

328 | setring @R; // ! |

329 | ====2 |

330 | 1:484c |

331 | 3:514c |

332 | setring save; |

333 | 2:559c |

334 | setring save; // !! |

335 | ====2 |

336 | 1:492c |

337 | 3:522c |

338 | setring @R; |

339 | 2:567c |

340 | setring @R; // !!! |

341 | ====2 |

342 | 1:494c |

343 | 3:524c |

344 | setring save; |

345 | 2:569c |

346 | setring save; // !!!! |

347 | ====2 |

348 | 1:513c |

349 | 3:543c |

350 | setring @R; |

351 | 2:588c |

352 | setring @R; // !!!!! |

353 | ====2 |

354 | 1:515c |

355 | 3:545c |

356 | setring save; |

357 | 2:590c |

358 | setring save; // !!!!! ! |

359 | ====2 |

360 | 1:517c |

361 | 3:547c |

362 | setring @R; |

363 | 2:592c |

364 | setring @R; // !!!!! !! |

365 | ====2 |

366 | 1:521c |

367 | 3:551c |

368 | setring save; |

369 | 2:596c |

370 | setring save; // !!!!! !!! |

371 | ====2 |

372 | 1:525c |

373 | 3:555c |

374 | setring @R; |

375 | 2:600,607c |

376 | setring @R; // !!!!! !!!! |

377 | |

378 | // TODO: UNBELIEVABLE PLENITUDE OF SETRING ABOVE! |

379 | // YOU CAN DO BETTER AS FOLLOWS: |

380 | // 1. GENERATE ONLY 1 (ONE!!!!) STRING sp FOR THE WHOLE(!!!) L |

381 | // BEFORE(!!!!) SWITCHING TO @R |

382 | // 2. EXECUTE IT IN @R |

383 | |

384 | ====2 |

385 | 1:533a |

386 | 3:563a |

387 | 2:616,618c |

388 | |

389 | // TODO: THE FOLLOWING DESERVES TO BE AN AUXILIARY PROCEDURE AS WELL! IS IT lp2lstr? |

390 | |

391 | ====2 |

392 | 1:540a |

393 | 3:570a |

394 | 2:626,628c |

395 | |

396 | // YOU HAVE A LOT OF SETRINGS BELOW, ARE YOU SURE THAT YOU CANNOT ELIMINATE SOME...? |

397 | |

398 | ====2 |

399 | 1:547c |

400 | 3:577c |

401 | setring save; |

402 | 2:635c |

403 | setring save; // ! |

404 | ====2 |

405 | 1:553c |

406 | 3:583c |

407 | setring @R; |

408 | 2:641c |

409 | setring @R; // !! |

410 | ====2 |

411 | 1:580a |

412 | 3:610a |

413 | 2:669c |

414 | |

415 | ====2 |

416 | 1:585c |

417 | 3:615c |

418 | setring @R; |

419 | 2:674c |

420 | setring @R; // !!! |

421 | ====2 |

422 | 1:595c |

423 | 3:625c |

424 | setring save; |

425 | 2:684c |

426 | setring save; // !!!! |

427 | ====2 |

428 | 1:624c |

429 | 3:654c |

430 | setring @R; |

431 | 2:713c |

432 | setring @R; // !!!!! |

433 | ====2 |

434 | 1:628c |

435 | 3:658c |

436 | setring save; |

437 | 2:717c |

438 | setring save; // !!!!! ! |

439 | ====2 |

440 | 1:632c |

441 | 3:662c |

442 | setring save; |

443 | 2:721c |

444 | setring save; // !!!!! !! |

445 | ====2 |

446 | 1:644a |

447 | 3:674a |

448 | 2:734,762c |

449 | kill U; |

450 | setring r; // non-homog. input: |

451 | M = [-1,x,y],[-7,y,y,z],[3,x,x,x,z,z]; |

452 | N = [1,x,y,z,x],[-1,y,x,y]; |

453 | L[1] = M; L[2] = N; |

454 | lst2str(L); |

455 | def U = freegbasis(L,5); |

456 | lst2str(U); // OK |

457 | kill U,r; |

458 | ring r = 0,(x,y,z),(dp(1),dp(2)); |

459 | def R = nc_algebra(1,0); setring R; // should be the same as 1st! |

460 | module M = [-1,x,y],[-7,y,y],[3,x,x]; |

461 | module N = [1,x,y,x],[-1,y,x,y]; |

462 | list L; L[1] = M; L[2] = N; |

463 | lst2str(L); |

464 | def U = freegbasis(L,5); |

465 | lst2str(U); // OK |

466 | kill U, R; |

467 | setring r; |

468 | def R = nc_algebra(-1,1); setring R; // some non-commutativity |

469 | R; |

470 | module M = [-1,x,y],[-7,y,y],[3,x,x]; |

471 | module N = [1,x,y,x],[-1,y,x,y]; |

472 | list L; L[1] = M; L[2] = N; |

473 | lst2str(L); |

474 | def U = freegbasis(L,5); |

475 | lst2str(U); |

476 | |

477 | |

478 | ====3 |

479 | 1:647c |

480 | 2:765c |

481 | proc crs(list LM, int d) |

482 | 3:677c |

483 | static proc crs(list LM, int d) |

484 | ====3 |

485 | 1:796c |

486 | 2:914c |

487 | proc polylen(ideal I) |

488 | 3:826c |

489 | static proc polylen(ideal I) |

490 | ====2 |

491 | 1:811a |

492 | 3:841a |

493 | 2:930,938c |

494 | |

495 | // TODO: ASSUMPTIONS? |

496 | // TODO: PROC FORGETS ABOUT NON-COMM. RELATIONS IN THE |

497 | //// BASERING! DOCUMENT IT OR FIX... |

498 | // TODO: WRITE DOWN WHAT IS THE ORDERING IN THE OUTPUT RING? |

499 | // TODO: OVERSIMPLIFIED: WHAT IF PARAMETERS HAVE BRACKETS |

500 | //// AND COINCIDE WITH GENERATED VARIABLES? SEE EXAMPLE |

501 | |

502 | |

503 | ====2 |

504 | 1:822c |

505 | 3:852c |

506 | int ppl = printlevel-voice+2; |

507 | 2:949c |

508 | int ppl = printlevel-voice+2; |

509 | ====2 |

510 | 1:885,886c |

511 | 3:915,916c |

512 | def A = freegbRing(2); |

513 | setring A; |

514 | 2:1012,1013c |

515 | r; |

516 | def A = freegbRing(2); setring A; |

517 | ====2 |

518 | 1:887a |

519 | 3:917a |

520 | 2:1015,1032c |

521 | kill A, r; |

522 | ring r = 0,(x(1..3)),(dp(1),lp(2)); |

523 | r; |

524 | def A = freegbRing(2); setring A; |

525 | A; // OK |

526 | kill A, r; |

527 | ring r = (0,a(1),b(1)),(a, b),(lp(1),dp(1)); |

528 | r; |

529 | def A = freegbRing(2); setring A; |

530 | A; // BUG: parameter should not be named as a variable and vice verse! |

531 | a(1); typeof(a(1)); |

532 | kill A, r; |

533 | ring r = 0,(x,y,z),dp; |

534 | def R = nc_algebra(-1, 1); setring R; |

535 | R; |

536 | def A = freegbRing(2); setring A; |

537 | A; // NOTE: the putput is a purely commutative ring! |

538 | kill A, R, r; |

539 | ====3 |

540 | 1:890c |

541 | 2:1035c |

542 | proc ex_shift() |

543 | 3:920,922c |

544 | /* EXAMPLES: |

545 | |

546 | //static proc ex_shift() |

547 | ====3 |

548 | 1:911c |

549 | 2:1056c |

550 | proc test_shrink() |

551 | 3:943c |

552 | //static proc test_shrink() |

553 | ====3 |

554 | 1:938c |

555 | 2:1083c |

556 | proc ex2() |

557 | 3:970c |

558 | //static proc ex2() |

559 | ====3 |

560 | 1:948c |

561 | 2:1093c |

562 | proc ex_nonhomog() |

563 | 3:980c |

564 | //static proc ex_nonhomog() |

565 | ====3 |

566 | 1:966c |

567 | 2:1111c |

568 | proc ex_nonhomog_comm() |

569 | 3:998c |

570 | //static proc ex_nonhomog_comm() |

571 | ====3 |

572 | 1:976c |

573 | 2:1121c |

574 | proc ex_nonhomog_h() |

575 | 3:1008c |

576 | //static proc ex_nonhomog_h() |

577 | ====3 |

578 | 1:986c |

579 | 2:1131c |

580 | proc ex_nonhomog_h2() |

581 | 3:1018c |

582 | //static proc ex_nonhomog_h2() |

583 | ====3 |

584 | 1:1005c |

585 | 2:1150c |

586 | proc ex_nonhomog_3() |

587 | 3:1037c |

588 | //static proc ex_nonhomog_3() |

589 | ====3 |

590 | 1:1024c |

591 | 2:1169c |

592 | proc ex_densep_2() |

593 | 3:1056c |

594 | //static proc ex_densep_2() |

595 | ====3 |

596 | 1:1039a |

597 | 2:1184a |

598 | 3:1072,1074c |

599 | // END COMMENTED EXAMPLES |

600 | |

601 | */ |

602 | ====3 |

603 | 1:1048c |

604 | 2:1193c |

605 | proc freegbold(list LM, int d) |

606 | 3:1083c |

607 | static proc freegbold(list LM, int d) |

608 | ====3 |

609 | 1:1306c |

610 | 2:1451c |

611 | proc sgb(ideal I, int d) |

612 | 3:1341c |

613 | static proc sgb(ideal I, int d) |

614 | ====3 |

615 | 1:1329,1330c |

616 | 2:1474,1475c |

617 | |

618 | |

619 | 3:1363a |

620 | ====3 |

621 | 1:1344,1345c |

622 | 2:1489,1490c |

623 | |

624 | proc exHom1() |

625 | 3:1377c |

626 | static proc exHom1() |

627 | ====3 |

628 | 1:1422c |

629 | 2:1567c |

630 | proc schur2-3() |

631 | 3:1454c |

632 | static proc schur2-3() |

633 | ====3 |

634 | 1:1431a |

635 | 2:1576a |

636 | 3:1464,1470c |

637 | "USAGE: adem(i,j); i,j int |

638 | RETURN: ring and exports ideal |

639 | ASSUME: there are at least i+j variables in the basering |

640 | PURPOSE: compute the ideal of Adem relations for i<2j in characteristic 0 |

641 | @* the ideal is exported under the name AdemRel in the output ring |

642 | EXAMPLE: example adem; shows examples |

643 | " |

644 | ====3 |

645 | 1:1447c |

646 | 2:1592c |

647 | printf("k=0, term=%s",q); |

648 | 3:1486c |

649 | // printf("k=0, term=%s",q); |

650 | ====3 |

651 | 1:1453c |

652 | 2:1598c |

653 | printf("k=%s, term=%s",k,q); |

654 | 3:1492c |

655 | // printf("k=%s, term=%s",k,q); |

656 | ====3 |

657 | 1:1498,1501c |

658 | 2:1643,1646c |

659 | proc adem2mod(int n) |

660 | { |

661 | // Adem rels modulo 2 |

662 | } |

663 | 3:1537c |

664 | // Adem rels modulo 2 are interesting |

665 | ====3 |

666 | 1:1503c |

667 | 2:1648c |

668 | proc stringpoly2lplace(string s) |

669 | 3:1539c |

670 | static proc stringpoly2lplace(string s) |

671 | ====3 |

672 | 1:1649c |

673 | 2:1794c |

674 | proc addplaces(list L) |

675 | 3:1685c |

676 | static proc addplaces(list L) |

677 | ====3 |

678 | 1:1677c |

679 | 2:1822c |

680 | proc sent2lplace(string s) |

681 | 3:1713c |

682 | static proc sent2lplace(string s) |

683 | ====3 |

684 | 1:1696c |

685 | 2:1841c |

686 | proc testnumber(string s) |

687 | 3:1732c |

688 | static proc testnumber(string s) |

689 | ====3 |

690 | 1:1746c |

691 | 2:1891c |

692 | proc str2lplace(string s) |

693 | 3:1782c |

694 | static proc str2lplace(string s) |

695 | ====3 |

696 | 1:1823c |

697 | 2:1968c |

698 | proc strpower2rep(string s) |

699 | 3:1859c |

700 | static proc strpower2rep(string s) |

701 | ====3 |

702 | 1:1933a |

703 | 2:2078a |

704 | 3:1970,1978c |

705 | "USAGE: Liebr(a,b[,N]); a,b letterplace polynomials, N an optional integer |

706 | RETURN: poly |

707 | ASSUME: basering has a letterplace ring structure, like the one returned by freegbRing |

708 | @* Moreover, the variables 'uptodeg' (degree bound of the letterplace ring) and 'lV' (number of |

709 | blocks of variables of the letterplace ring ) must be defined |

710 | PURPOSE: compute the Lie bracket [a,b] = ab - ba between letterplace polynomials |

711 | NOTE: if N>1 is specified, then the left normed bracket [a,[...[a,b]]]] is computed. |

712 | EXAMPLE: example Liebr; shows examples |

713 | " |

714 | ====3 |

715 | 1:1934a |

716 | 2:2079a |

717 | 3:1980,1984c |

718 | |

719 | if (lpAssumeViolation()) |

720 | { |

721 | ERROR("Either 'uptodeg' or 'lV' global variables are not set!"); |

722 | } |

723 | ====3 |

724 | 1:1970a |

725 | 2:2115a |

726 | 3:2021c |

727 | kill uptodeg, lV; |

728 | ====3 |

729 | 1:1973c |

730 | 2:2118c |

731 | proc pmLiebr(poly a, poly b) |

732 | 3:2024c |

733 | static proc pmLiebr(poly a, poly b) |

734 | ====3 |

735 | 1:1986c |

736 | 2:2131c |

737 | proc pshift(poly a, int i) |

738 | 3:2037c |

739 | static proc pshift(poly a, int i) |

740 | ====3 |

741 | 1:1989a |

742 | 2:2134a |

743 | 3:2041,2044c |

744 | if (deg(a) + i > uptodeg) |

745 | { |

746 | ERROR("degree bound violated by the shift!"); |

747 | } |

748 | ====3 |

749 | 1:1993c |

750 | 2:2138c |

751 | proc mmLiebr(poly a, poly b) |

752 | 3:2048c |

753 | static proc mmLiebr(poly a, poly b) |

754 | ====3 |

755 | 1:2014a |

756 | 2:2159a |

757 | 3:2070c |

758 | kill uptodeg, lV; |

759 | ====3 |

760 | 1:2017a |

761 | 2:2162a |

762 | 3:2074,2080c |

763 | "USAGE: Serre(A,z); A an intmat, z an int |

764 | RETURN: ideal |

765 | ASSUME: basering has a letterplace ring structure and |

766 | @* A is a generalized Cartan matrix with integer entries |

767 | PURPOSE: compute the ideal of Serre's relations associated to A |

768 | EXAMPLE: example Serre; shows examples |

769 | " |

770 | ====3 |

771 | 1:2025c |

772 | 2:2170c |

773 | int i,j,k,l; |

774 | 3:2088c |

775 | int i,j,k,el; |

776 | ====3 |

777 | 1:2032c |

778 | 2:2177c |

779 | l = 1 - A[i,j]; |

780 | 3:2095c |

781 | el = 1 - A[i,j]; |

782 | ====3 |

783 | 1:2034c |

784 | 2:2179c |

785 | dbprint(ppl,"i, j, l: ",i,j,l); |

786 | 3:2097c |

787 | dbprint(ppl,"i, j, l: ",i,j,el); |

788 | ====3 |

789 | 1:2037c |

790 | 2:2182c |

791 | if ((i!=j) && (l >0)) |

792 | 3:2100c |

793 | if ((i!=j) && (el >0)) |

794 | ====3 |

795 | 1:2040c |

796 | 2:2185c |

797 | // printf("first bracket: %s",q); |

798 | 3:2102a |

799 | ====3 |

800 | 1:2044c |

801 | 2:2189c |

802 | for (k=1; k<=l-1; k++) |

803 | 3:2106c |

804 | for (k=1; k<=el-1; k++) |

805 | ====3 |

806 | 1:2047c |

807 | 2:2192c |

808 | // printf("further bracket: %s",q); |

809 | 3:2108a |

810 | ==== |

811 | 1:2061,2063c |

812 | intmat A[2][2] = 2, -1, -1, 2; // sl_3 == A_2 |

813 | ring r = 0,(f1,f2),dp; |

814 | int uptodeg = 3; int lV = 2; |

815 | 2:2206,2209c |

816 | intmat A[2][2] = 2, -1, -1, 2; // sl_3 == A_2 |

817 | ring r = 0,(f1,f2),dp; |

818 | int uptodeg = 3; |

819 | int lV = 2; |

820 | 3:2122,2127c |

821 | intmat A[3][3] = |

822 | 2, -1, 0, |

823 | -1, 2, -3, |

824 | 0, -1, 2; // G^1_2 Cartan matrix |

825 | ring r = 0,(f1,f2,f3),dp; |

826 | int uptodeg = 5; int lV = 3; |

827 | ====3 |

828 | 1:2067c |

829 | 2:2213c |

830 | ideal I = Serre(A,1); |

831 | 3:2131c |

832 | ideal I = Serre(A,1); I = simplify(I,1+2+8); |

833 | ====3 |

834 | 1:2069c |

835 | 2:2215c |

836 | Serre(A,0); |

837 | 3:2133c |

838 | kill uptodeg, lV; |

839 | ==== |

840 | 1:2071a |

841 | 2:2218,2221c |

842 | // TODO: EXPLAIN CONVERTION RULE, ENCODING OF 'LN'! |

843 | // THIS SEEMS TO BE THE LAST PART OF FREEGBASIS? |

844 | // TODO: ASSUMPTIONS! WHY NO SQUARES IN ELEMENTS FROM K? |

845 | |

846 | 3:2136,2141c |

847 | /* setup for older example: |

848 | intmat A[2][2] = 2, -1, -1, 2; // sl_3 == A_2 |

849 | ring r = 0,(f1,f2),dp; |

850 | int uptodeg = 5; int lV = 2; |

851 | */ |

852 | |

853 | ====3 |

854 | 1:2073,2075c |

855 | 2:2223,2225c |

856 | "USAGE: lp2lstr(K,save); K an ideal, save a ring |

857 | RETURN: nothing (exports object LN into save) |

858 | PURPOSE: converts letter-place ideal to list of modules |

859 | 3:2143,2147c |

860 | "USAGE: lp2lstr(K,s); K an ideal, s a ring |

861 | RETURN: nothing (exports object LN into s) |

862 | ASSUME: basering has a letterplace ring structure |

863 | PURPOSE: converts letterplace ideal to list of modules |

864 | NOTE: useful as preprocessing to 'lst2str' |

865 | ====2 |

866 | 1:2097a |

867 | 3:2169a |

868 | 2:2248,2250c |

869 | |

870 | // TODO: YOU CAN FOLD TWO FOLLOWING LOOPS TOGETHER! |

871 | // THE FOLLOWING CHECK/PREPROCESSING MIGHT BE EXPENSIVE! |

872 | ====2 |

873 | 1:2180,2181c |

874 | 3:2252,2253c |

875 | int uptodeg = 3; int lV = 2; |

876 | export uptodeg; export lV; |

877 | 2:2333c |

878 | int uptodeg = 3; |

879 | ====2 |

880 | 1:2184c |

881 | 3:2256c |

882 | ideal I = Serre(A,1); |

883 | 2:2336,2341c |

884 | ideal I = Serre(A,1); // TODO: BUG: WHY IS THIS FAILED??? HIDING ARGUMENTS IS A BAD STYLE!!! |

885 | |

886 | int lV = 2; // NOT CLEAR WHERE DO YOU NEED THIS? |

887 | export uptodeg; export lV; // TODO: BUG: THEY WHERE NOR DEFINED BEFORE IN CODE!!! |

888 | I = Serre(A,1); |

889 | |

890 | ====2 |

891 | 1:2188c |

892 | 3:2260c |

893 | kill uptodeg; kill lV; |

894 | 2:2345,2348c |

895 | |

896 | |

897 | kill uptodeg; |

898 | kill lV; |

899 | ====3 |

900 | 1:2191c |

901 | 2:2351c |

902 | proc strList2poly(list L) |

903 | 3:2263c |

904 | static proc strList2poly(list L) |

905 | ====3 |

906 | 1:2231c |

907 | 2:2391c |

908 | proc file2lplace(string fname) |

909 | 3:2303,2308c |

910 | static proc file2lplace(string fname) |

911 | "USAGE: file2lplace(fnm); fnm a string |

912 | RETURN: ideal |

913 | PURPOSE: convert the contents of the file fnm into ideal of polynomials in free algebra |

914 | EXAMPLE: example file2lplace; shows examples |

915 | " |

916 | ====3 |

917 | 1:2289c |

918 | 2:2449c |

919 | static proc get_ls3nilp() |

920 | 3:2366,2367c |

921 | /* EXAMPLES AGAIN: |

922 | //static proc get_ls3nilp() |

923 | ====3 |

924 | 1:2303c |

925 | 2:2463c |

926 | static proc doc_example |

927 | 3:2381c |

928 | //static proc doc_example() |

929 | ====3 |

930 | 1:2320c |

931 | 2:2480c |

932 | |

933 | 3:2398c |

934 | */ |

935 | ====3 |

936 | 1:2325a |

937 | 2:2485a |

938 | 3:2404,2448c |

939 | proc lpMult(poly f, poly g) |

940 | "USAGE: lpMult(f,g); f,g letterplace polynomials |

941 | RETURN: poly |

942 | ASSUME: basering has a letterplace ring structure, like the one returned by freegbRing |

943 | @* Moreover, the variables 'uptodeg' (degree bound of the letterplace ring) and 'lV' (number of |

944 | blocks of variables of the letterplace ring ) must be defined |

945 | PURPOSE: compute the letterplace form of f*g |

946 | EXAMPLE: example lpMult; shows examples |

947 | " |

948 | { |

949 | if (lpAssumeViolation()) |

950 | { |

951 | ERROR("Either 'uptodeg' or 'lV' global variables are not set!"); |

952 | } |

953 | int sf = deg(f); |

954 | int sg = deg(g); |

955 | if (sf+sg > uptodeg) |

956 | { |

957 | ERROR("degree bound violated by the product!"); |

958 | } |

959 | // if (sf>1) { sf = sf -1; } |

960 | poly v = f*pshift(g,sf); |

961 | return(v); |

962 | } |

963 | example |

964 | { |

965 | "EXAMPLE:"; echo = 2; |

966 | // define a ring in letterplace form as follows: |

967 | ring r = 0,(x(1),y(1),x(2),y(2),x(3),y(3),x(4),y(4)),dp; |

968 | poly a = x(1)*y(2); poly b = y(1); |

969 | int uptodeg=4; int lV=2; |

970 | export uptodeg; export lV; |

971 | lpMult(b,a); |

972 | lpMult(a,b); |

973 | kill uptodeg, lV; |

974 | } |

975 | |

976 | static proc lpAssumeViolation() |

977 | { |

978 | // checks whether the global vars |

979 | // uptodeg and lV are defined |

980 | // returns Boolean : yes/no [for assume violation] |

981 | int i = ( defined(uptodeg) && (defined(lV)) ); |

982 | return ( !i ); |

983 | } |