Changeset 6b6c82 in git
- Timestamp:
- Apr 27, 2012, 9:26:56 PM (11 years ago)
- Branches:
- (u'spielwiese', '0d6b7fcd9813a1ca1ed4220cfa2b104b97a0a003')
- Children:
- 8f57c0f58364149bf1fbc74361c05edbe29a0b09
- Parents:
- 8d2416350137aae4bb844cb2c39b1bb14b7b5776
- git-author:
- Oleksandr Motsak <motsak@mathematik.uni-kl.de>2012-04-27 21:26:56+02:00
- git-committer:
- Oleksandr Motsak <motsak@mathematik.uni-kl.de>2012-05-10 18:23:39+02:00
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/LIB/schreyer.lib
r8d2416 r6b6c82 381 381 RES; 382 382 MRES; 383 384 383 } 385 384 … … 434 433 } 435 434 435 436 437 // ================================================================== // 438 439 440 LIB "general.lib"; // for sort 441 442 // TODO: in C++! 443 static proc Tail(def M) 444 { 445 int i = ncols(M); def m; 446 while (i > 0) 447 { 448 m = M[i]; 449 450 m = m - lead(m); // m = tail(m) 451 452 M[i] = m; 453 454 i--; 455 } 456 return (M); 457 } 458 459 /* static */ proc SSinit(module M) 460 { 461 if( (typeof(M) != "module") && (typeof(M) != "ideal") ) 462 { 463 ERROR("Sorry: need an ideal or a module for input"); 464 } 465 466 // TODO! DONE? 467 def @save = basering; 468 469 int @DEBUG = !system("with", "ndebug"); 470 if( @DEBUG ) 471 { 472 "SSinit::Input"; 473 type(M); 474 DetailedPrint(M); 475 attrib(M); 476 } 477 478 int @RANK = nrows(M); int @SIZE = ncols(M); 479 480 int @IS_A_SB = attrib(M, "isSB"); // ??? only if all weights were zero?! 481 482 if( !@IS_A_SB ) 483 { 484 def opts = option(get); 485 option(redSB); option(redTail); 486 M = std(M); 487 option(set, opts); 488 kill opts; 489 } else 490 { 491 M = simplify(M, 2 + 4 + 32); 492 } 493 494 def LEAD = lead(M); 495 496 // sort wrt neg.deg.rev.lex! 497 intvec iv_ds = sort(LEAD, "ds", 1)[2]; // ,1 => reversed! 498 499 M = M[iv_ds]; // sort M wrt ds on current leading terms 500 LEAD = LEAD[iv_ds]; 501 502 def TAIL = Tail(M); 503 504 intvec @DEGS = deg(M[1..@SIZE]); // store actuall degrees of input elements 505 506 // TODO: what about real modules? weighted ones? 507 508 list @l = ringlist(@save); 509 510 int @z = 0; ideal @m = maxideal(1); intvec @wdeg = deg(@m[1..ncols(@m)]); 511 512 // NOTE: @wdeg will be ignored anyway :( 513 @l[3] = list(list("C", @z), list("lp", @wdeg)); 514 515 kill @z, @wdeg; // since these vars are ring independent! 516 517 def S = ring(@l); // --MakeInducedSchreyerOrdering(1); 518 519 module F = freemodule(@RANK); 520 intvec @V = deg(F[1..@RANK]); 521 522 setring S; // ring with an easy divisibility test ("C, lex") 523 524 if( @DEBUG ) 525 { 526 "SSinit::StartingISRing"; 527 basering; 528 // DetailedPrint(basering); 529 } 530 531 // Setup the leading syzygy^{-1} module to zero: 532 module Z = 0; Z[@RANK] = 0; attrib(Z, "isHomog", intvec(0)); 533 534 module MRES = Z; 535 536 list RES; RES[1] = Z; 537 list LRES; LRES[1] = Z; 538 list TRES; TRES[1] = Z; 539 540 def M = imap(@save, M); 541 attrib(M, "isHomog", @V); 542 attrib(M, "isSB", 1); 543 544 attrib(M, "degrees", @DEGS); 545 546 def LEAD = imap(@save, LEAD); 547 attrib(LEAD, "isHomog", @V); 548 attrib(LEAD, "isSB", 1); 549 550 def TAIL = imap(@save, TAIL); 551 552 if( @DEBUG ) 553 { 554 "SSinit::(sorted) SB_Input: "; 555 type(M); 556 attrib(M); 557 attrib(M, "isHomog"); 558 DetailedPrint(M); 559 } 560 561 // 0^th syz. property 562 if( size(module(transpose( transpose(M) * transpose(MRES) ))) > 0 ) 563 { 564 transpose( transpose(M) * transpose(MRES) ); 565 "ERROR: transpose( transpose(M) * transpose(MRES) ) != 0!!!"; 566 $ 567 } 568 569 RES[size(RES)+1] = M; // list of all syzygy modules 570 LRES[size(LRES)+1] = LEAD; // list of all syzygy modules 571 TRES[size(TRES)+1] = TAIL; // list of all syzygy modules 572 573 MRES = MRES, M; //? 574 575 attrib(MRES, "isHomog", @V); 576 577 attrib(S, "InducionStart", @RANK); 578 579 if( @DEBUG ) 580 { 581 "SSinit::MRES"; 582 DetailedPrint(MRES); 583 attrib(MRES, "isHomog"); 584 attrib(S); 585 } 586 587 export RES; 588 export MRES; 589 export LRES; 590 export TRES; 591 return (S); 592 } 593 example 594 { "EXAMPLE:"; echo = 2; 595 ring R = 0, (w, x, y, z), dp; 596 597 def M = maxideal(1); 598 def S = SSinit(M); setring S; S; 599 600 "Only the first initialization: "; 601 RES; LRES; TRES; 602 MRES; 603 604 kill S; setring R; kill M; 605 606 ideal M = w^2 - x*z, w*x - y*z, x^2 - w*y, x*y - z^2, y^2 - w*z; 607 def S = SSinit(M); setring S; S; 608 609 "Only the first initialization: "; 610 RES; LRES; TRES; 611 MRES; 612 613 kill S; setring R; kill M; 614 } 615 616 // module (N, LL, TT) = SSComputeSyzygy(L, T, @RANK); // shift syz.comp by @RANK! 617 proc SSComputeSyzygy(def M, def L, def T, int iCompShift) 618 { 619 int @DEBUG = !system("with", "ndebug"); 620 621 if( @DEBUG ) 622 { 623 "SSComputeSyzygy::Input"; 624 "basering: ", basering; attrib(basering); 625 // DetailedPrint(basering); 626 627 "iCompShift: ", iCompShift; 628 629 "M: "; M; 630 "L: "; L; 631 "T: "; T; 632 } 633 634 635 // !!!!!!!!!!!!!!!!!!!!!!!!!!!! TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!! // 636 // !!!!!!!!!!!!!!!!!!!!!!!!!!!! TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!! // 637 // !!!!!!!!!!!!!!!!!!!!!!!!!!!! TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!! // 638 // !!!!!!!!!!!!!!!!!!!!!!!!!!!! TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!! // 639 // !!!!!!!!!!!!!!!!!!!!!!!!!!!! TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!! // 640 // !!!!!!!!!!!!!!!!!!!!!!!!!!!! TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!! // 641 // !!!!!!!!!!!!!!!!!!!!!!!!!!!! TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!! // 642 643 644 def opts = option(get); option(redSB); option(redTail); 645 module SYZ = std(syz(M)); // TODO: !!!!!!!!!!! 646 option(set, opts); kill opts; 647 648 "SYZ: "; SYZ; print(SYZ); 649 650 module Z; Z[iCompShift] = 0; Z = Z, transpose(SYZ); SYZ = transpose(Z); 651 652 "shifted SYZ: "; SYZ; print(SYZ); 653 654 module LL, TT; 655 656 LL = lead(SYZ); // TODO: WRONG ORDERING!!!!!!!! 657 TT = Tail(SYZ); 658 659 660 // !!!!!!!!!!!!!!!!!!!!!!!!!!!! TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!! // 661 // !!!!!!!!!!!!!!!!!!!!!!!!!!!! TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!! // 662 // !!!!!!!!!!!!!!!!!!!!!!!!!!!! TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!! // 663 // !!!!!!!!!!!!!!!!!!!!!!!!!!!! TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!! // 664 // !!!!!!!!!!!!!!!!!!!!!!!!!!!! TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!! // 665 // !!!!!!!!!!!!!!!!!!!!!!!!!!!! TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!! // 666 // !!!!!!!!!!!!!!!!!!!!!!!!!!!! TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!! // 667 668 intvec iv_ds = sort(LL, "ds", 1)[2]; // ,1 => reversed! 669 LL = LL[iv_ds]; 670 TT = TT[iv_ds]; 671 672 if( @DEBUG ) 673 { 674 "SSComputeSyzygy::Output"; 675 676 "SYZ: "; SYZ; 677 "LL: "; LL; 678 "TT: "; TT; 679 } 680 681 return (SYZ, LL, TT); 682 } 683 684 // resolution/syzygy step: 685 static proc SSstep() 686 { 687 /// TODO!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 688 int @DEBUG = !system("with", "ndebug"); 689 690 if( @DEBUG ) 691 { 692 "SSstep::NextInducedRing"; 693 "basering: ", basering; attrib(basering); 694 // DetailedPrint(basering); 695 } 696 697 /* 698 // is initial weights are all zeroes! 699 def L = lead(M); 700 intvec @V = deg(M[1..ncols(M)]); @W; @V; @W = @V; attrib(L, "isHomog", @W); 701 SetInducedReferrence(L, @RANK, 0); 702 */ 703 704 // def L = lead(MRES); 705 // @W = @W, @V; 706 // attrib(L, "isHomog", @W); 707 708 709 // General setting: 710 // SetInducedReferrence(MRES, 0, 0); // limit: 0! 711 int @l = size(RES); 712 713 def M = RES[@l]; 714 715 def L = LRES[@l]; 716 def T = TRES[@l]; 717 718 719 //// TODO: wrong !!!!! 720 int @RANK = ncols(MRES) - ncols(M); // nrows(M); // what if M is zero?! 721 722 723 724 /* 725 if( @RANK != nrows(M) ) 726 { 727 type(MRES); 728 @RANK; 729 type(M); 730 pause(); 731 } 732 */ 733 734 intvec @W = attrib(M, "isHomog"); intvec @V = attrib(M, "degrees"); @V = @W, @V; 735 736 if( @DEBUG ) 737 { 738 "Sstep::NextInput: "; 739 M; 740 L; 741 @V; 742 @RANK; 743 DetailedPrint(MRES); 744 attrib(MRES, "isHomog"); 745 } 746 747 748 // TODO: N = SYZ( M )!!! 749 module N, LL, TT; (N, LL, TT) = SSComputeSyzygy(M, L, T, @RANK); // shift syz.comp by @RANK! 750 751 attrib(N, "isHomog", @V); 752 753 // TODO: correct the following: 754 intvec @DEGS = deg(N[1..ncols(N)]); // no mod. comp. weights :( 755 attrib(N, "degrees", @DEGS); 756 757 if( size(N) > 0 ) 758 { 759 N; 760 MRES; 761 // next syz. property 762 if( size(module(transpose( transpose(N) * transpose(MRES) ))) > 0 ) 763 { 764 MRES; 765 766 "N: "; N; // DetailedPrint(N, 2); 767 768 "LL:"; LL; // DetailedPrint(LL, 1); 769 "TT:"; TT; // DetailedPrint(TT, 10); 770 771 "RANKS: ", @RANK; 772 773 "transpose( transpose(N) * transpose(MRES) ) != 0!!!"; 774 transpose( transpose(N) * transpose(MRES) ); 775 776 "transpose(N) * transpose(MRES): "; 777 transpose(N) * transpose(MRES); 778 // DetailedPrint(module(_), 2); 779 $ 780 } 781 } 782 783 RES[@l + 1] = N; // list of all syzygy modules 784 LRES[@l + 1] = LL; // list of all syzygy modules 785 TRES[@l + 1] = TT; // list of all syzygy modules 786 787 MRES = MRES, N; 788 attrib(MRES, "isHomog", @V); 789 790 // L = L, lead(N); attrib(basering, "InducionLeads", L); 791 792 if( @DEBUG ) 793 { 794 "SSstep::NextSyzOutput: "; 795 DetailedPrint(N); 796 attrib(N); 797 } 798 799 } 800 801 proc SScontinue(int l) 802 "USAGE: SScontinue(l) 803 RETURN: nothing, instead it changes RES and MRES variables in the current ring 804 PURPOSE: computes further (at most l) syzygies 805 NOTE: must be used within a ring returned by Sres or Ssyz. RES and MRES are 806 explained in Sres 807 EXAMPLE: example Scontinue; shows an example 808 " 809 { 810 811 /// TODO! 812 // def data = GetInducedData(); 813 814 if( (!defined(RES)) || (!defined(MRES)) ) /* || (typeof(data) != "list") || (size(data) != 2) */ 815 { 816 ERROR("Sorry, but basering does not seem to be returned by Sres or Ssyz"); 817 } 818 for (; (l != 0) && (size(RES[size(RES)]) > 0); l-- ) 819 { 820 SSstep(); 821 } 822 } 823 example 824 { "EXAMPLE:"; echo = 2; 825 ring r; 826 module M = maxideal(1); M; 827 def S = SSsyz(M); setring S; S; 828 "Only the first syzygy: "; 829 RES; MRES; 830 "More syzygies: "; 831 SScontinue(10); 832 RES; MRES; 833 } 834 835 proc SSsyz(def M) 836 "USAGE: SSsyz(M) 837 RETURN: ring, containing a list of modules RES and a module MRES 838 PURPOSE: computes the first syzygy module of M (wrt some Schreyer ordering)? 839 NOTE: The output is explained in Sres 840 EXAMPLE: example Ssyz; shows an example 841 " 842 { 843 if( (typeof(M) != "module") && (typeof(M) != "ideal") ) 844 { 845 ERROR("Sorry: need an ideal or a module for input"); 846 } 847 848 def SS = SSinit(M); setring SS; 849 850 SSstep(); // NOTE: what if M is zero? 851 852 return (SS); 853 } 854 example 855 { "EXAMPLE:"; echo = 2; 856 ring r; 857 858 /* ideal M = 0; 859 def S = SSsyz(M); setring S; S; 860 "Only the first syzygy: "; 861 RES; LRES; TRES; 862 MRES; 863 864 kill S; setring r; kill M; 865 */ 866 867 module M = maxideal(1); M; 868 def S = SSsyz(M); setring S; S; 869 "Only the first syzygy: "; 870 RES; LRES; TRES; 871 MRES; 872 873 kill S; setring r; kill M; 874 875 kill r; 876 877 ring R = 0, (w, x, y, z), dp; 878 ideal M = w^2 - x*z, w*x - y*z, x^2 - w*y, x*y - z^2, y^2 - w*z; 879 880 def S = SSsyz(M); setring S; S; 881 "Only the first syzygy: "; 882 RES; LRES; TRES; 883 MRES; 884 } 885 886 proc SSres(def M, int l) 887 "USAGE: SSres(I, l) 888 RETURN: ring, containing a list of modules RES and a module MRES 889 PURPOSE: computes (at most l) syzygy modules of M wrt the classical Schreyer 890 induced ordering with gen(i) > gen(j) if i > j, provided both gens 891 are from the same syzygy level.??? 892 NOTE: RES contains the images of maps subsituting the beginning of the 893 Schreyer free resolution of baseRing^r/M, while MRES is a sum of 894 these images in a big free sum, containing all the syzygy modules. 895 The syzygy modules are shifted so that gen(i) correspons to MRES[i]. 896 The leading zero module RES[0] indicates the fact that coker of the 897 first map is zero. The number of zeroes inducates the rank of input. 898 NOTE: If l == 0 then l is set to be nvars(basering) + 1 899 EXAMPLE: example SSres; shows an example 900 " 901 { 902 if( (typeof(M) != "module") && (typeof(M) != "ideal") ) 903 { 904 ERROR("Sorry: need an ideal or a module for input"); 905 } 906 907 def SS = SSinit(M); setring SS; 908 909 if (l == 0) 910 { 911 l = nvars(basering) + 1; // not really an estimate...?! 912 } 913 914 SSstep(); l = l - 1; 915 916 SScontinue(l); 917 918 return (SS); 919 } 920 example 921 { "EXAMPLE:"; echo = 2; 922 ring r; 923 module M = maxideal(1); M; 924 def S = SSres(M, 0); setring S; S; 925 RES; 926 MRES; 927 kill S; 928 setring r; kill M; 929 930 def A = nc_algebra(-1,0); setring A; 931 ideal Q = var(1)^2, var(2)^2, var(3)^2; 932 qring SCA = twostd(Q); 933 basering; 934 935 module M = maxideal(1); 936 def S = SSres(M, 2); setring S; S; 937 RES; 938 MRES; 939 } 436 940 437 941 … … 550 1054 example Sres; 551 1055 } 1056 1057 proc testallSSexamples() 1058 { 1059 example SSsyz; 1060 example SScontinue; 1061 example SSres; 1062 } 1063 552 1064 example 553 1065 { "EXAMPLE:"; echo = 2; 554 1066 testallSexamples(); 555 } 1067 testallSSexamples(); 1068 }
Note: See TracChangeset
for help on using the changeset viewer.