This file is indexed.

/usr/share/singular/LIB/JMBTest.lib is in singular-data 4.0.3+ds-1.

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
 387
 388
 389
 390
 391
 392
 393
 394
 395
 396
 397
 398
 399
 400
 401
 402
 403
 404
 405
 406
 407
 408
 409
 410
 411
 412
 413
 414
 415
 416
 417
 418
 419
 420
 421
 422
 423
 424
 425
 426
 427
 428
 429
 430
 431
 432
 433
 434
 435
 436
 437
 438
 439
 440
 441
 442
 443
 444
 445
 446
 447
 448
 449
 450
 451
 452
 453
 454
 455
 456
 457
 458
 459
 460
 461
 462
 463
 464
 465
 466
 467
 468
 469
 470
 471
 472
 473
 474
 475
 476
 477
 478
 479
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
 493
 494
 495
 496
 497
 498
 499
 500
 501
 502
 503
 504
 505
 506
 507
 508
 509
 510
 511
 512
 513
 514
 515
 516
 517
 518
 519
 520
 521
 522
 523
 524
 525
 526
 527
 528
 529
 530
 531
 532
 533
 534
 535
 536
 537
 538
 539
 540
 541
 542
 543
 544
 545
 546
 547
 548
 549
 550
 551
 552
 553
 554
 555
 556
 557
 558
 559
 560
 561
 562
 563
 564
 565
 566
 567
 568
 569
 570
 571
 572
 573
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
//////////////////////////////////////////////////////////////////////
version="version JMBTest.lib 4.0.0.0 Jun_2013 "; // $Id: aba2de11ed1e911bbf56c65b39cfd2621b578a49 $
category="Algebraic Geometry";
// summary description of the library
info="
LIBRARY:   JMBTest.lib  A library for Singular which performs JM basis test.
AUTHOR:    Michela Ceria, email: michela.ceria@unito.it

SEE ALSO:  JMSConst_lib
KEYWORDS:  J-marked schemes

OVERVIEW:
The library performs the J-marked basis test, as described in [CR], [BCLR].
Such a test is performed via the criterion explained in [BCLR],
concerning Eliahou-Kervaire polynomials (EK from now on).
We point out that all the polynomials are homogeneous
and they must be arranged by degree.
The fundamental steps are the following:@*
-construct the Vm polynomials, via the algorithm VConstructor
explained in [CR];@*
-construct the Eliahou-Kervaire polynomials defined in [BCLR];@*
-reduce the  Eliahou-Kervaire polynomials using the Vm's;@*
-if it exist an Eliahou-Kervaire polynomial such that its reduction
mod Vm is different from zero, the given one is not a J-Marked basis.

The algorithm terminates only if the ordering is rp.
Anyway, the number of reduction steps is bounded.

REFERENCES:
[CR] Francesca Cioffi, Margherita Roggero,Flat Families by Strongly
Stable Ideals and a Generalization of Groebner Bases,
J. Symbolic Comput. 46,  1070-1084, (2011).@*
[BCLR] Cristina Bertone, Francesca Cioffi, Paolo Lella,
Margherita Roggero, Upgraded methods for the effective
computation of marked schemes on a strongly stable ideal,
Journal of Symbolic Computation
(2012), http://dx.doi.org/10.1016/j.jsc.2012.07.006 @*

PROCEDURES:
  Minimus(ideal)            minimal variable in an ideal
  Maximus(ideal)               maximal variable in an ideal
  StartOrderingV(list,list)     ordering of polynomials as in [BCLR]
  TestJMark(list)           tests whether we have a J-marked basis
";
LIB "qhmoduli.lib";
LIB "monomialideal.lib";
LIB "ring.lib";
////////////////////////////////////////////////////////////////////
proc mod_init()
"USAGE:     mod_init();
RETURN:   struct: jmp
EXAMPLE:  example  mod_init; shows an example"
{
newstruct("jmp", "poly h, poly t");
}
example
{ "EXAMPLE:"; echo = 2;
  mod_init();
}
////////////////////////////////////////////////////////////////////
proc Terns(list G, int c)
"USAGE:    Terns(G,c); G list, c int
RETURN:   list: T
NOTE:     Input is a list of J-marked  polynomials
(arranged by degree) and an integer.
EXAMPLE:  example Terns; shows an example"
{
list T=list();
int z;
 for(int k=1; k<=size(G[c]);k=k+1)
    {
//Loop on G[c] making positions of polynomials in G[c]
      z=size(T);
      T=insert(T,list(1,c,k) ,size(T));
    }
return(T);
}
example
{ "EXAMPLE:"; echo = 2;
ring r=0, (x,y,z), rp;
jmp r1;
r1.h=z^3;
r1.t=poly(0);
jmp r2;
r2.h=z^2*y;
r2.t=poly(0);
jmp r3;
r3.h=z*y^2 ;
r3.t=-x^2*y;
jmp r4;
r4.h=y^5;
r4.t=poly(0);
list G2F=list(list(r1,r2,r3),list(r4));
Terns(G2F, 1);
Terns(G2F, 2);
}
////////////////////////////////////////////////////////////////////
proc VConst(list G, int c)
"USAGE:    VConst(G, c); G list, c int
RETURN:   list: V
NOTES: this procedure computes the Vm polynomials following the
algorithm in [CR],but it only keeps in memory the monomials by
which the G's must be multplied and their positions.
EXAMPLE:  example VConst; shows an example"
{
jmp f=G[1][1];
int aJ=deg(f.h);
// minimal degree of polynomials in G
//print(aJ);
list V=list();
V[1]=Terns(G,1);
// V[1]=G[1] (keeping in memory only [head, position])
//print(c-aJ+1);
int i;
int j;
int m;
list OO;
jmp p;
  for(m=2; m<=c-aJ+1; m=m+1)
  {
     //print("entro nel form");
     if(m>size(G))
        {V[m]=list();
//If we have not G[m] we insert a list()
        //print("vuota prima");
        }
     else
        {V[m]=Terns(G,m);
        //print("piena prima");
        }
     for(i=1; i<nvars(basering)+1; i=i+1)
        {
          //print("entrata fori");
          //print(i);
          for(j=1; j<=size(V[m-1]); j=j+1)
             {
                   p=G[V[m-1][j][2]][V[m-1][j][3]];
                  //print(p.h);
                  //print(p.t);
                  //print(var(i));
                  //print(Minimus(V[m-1][j][1]*p.h));
               if(var(i)<=Minimus(variables(V[m-1][j][1]*p.h)))
                  {
//Can I multiply by the current variable?
                    //print("minoremin");
                    //print("fin qui ci sono");
                     //print(V[m-1][j][1]);
                     OO=list(var(i)*V[m-1][j][1],V[m-1][j][2],V[m-1][j][3]);
                    V[m]=insert(V[m], OO ,size(V[m]));
                  }
             }
        }
  }
return (V);}
example
{ "EXAMPLE:"; echo = 2;
 ring r=0, (x,y,z), rp;
jmp r1;
r1.h=z^3;
r1.t=poly(0);
jmp r2;
r2.h=z^2*y;
r2.t=poly(0);
jmp r3;
r3.h=z*y^2 ;
r3.t=-x^2*y;
jmp r4;
r4.h=y^5;
r4.t=poly(0);
list G2F=list(list(r1,r2,r3),list(r4));
VConst(G2F,4,basering);}
////////////////////////////////////////////////////////////////////
proc Minimus(ideal L)
"USAGE:    Minimus(L); G list, c int
RETURN:   list: V
NOTES: it returns the minimal variable generating the ideal L.@*
The input must be an ideal generated by variables.
EXAMPLE:  example Minimus; shows an example"
{
poly min=L[1];
int i;
for(i=2;i<=size(L); i++)
  {
    if(L[i]<min){min=L[i];}
  }
return(min);
}
example
{ "EXAMPLE:"; echo = 2;
 ring r=0, (x,y,z), rp;
ideal I=y,x,z;
Minimus(I);
}
////////////////////////////////////////////////////////////////////
proc Maximus(ideal L)
"USAGE:    Maximus(L); G list, c int
RETURN:   list: V
NOTES: it returns the maximal variable generating the ideal L.@*
The input must be an ideal generated by variables.
EXAMPLE:  example Maximus; shows an example"
{
poly max=L[1];
int i;
for(i=2;i<=size(L); i++)
  {
    if(L[i]>max){max=L[i];}
  }
return(max);
}
example
{ "EXAMPLE:"; echo = 2;
 ring r=0, (x,y,z), rp;
ideal I=y,x,z;
Maximus(I);
}
////////////////////////////////////////////////////////////////////
proc GJmpMins(jmp P, jmp Q)
"USAGE:    GJmpMins(P,Q); P jmp, Q jmp
RETURN:   int: d
EXAMPLE:  example GJmpMins; shows an example"
{
  int d=1;
//-1=lower, 0=equal, 1=higher
//At the beginning suppose Q is higher
  if(deg(P.h)<deg(Q.h))
     {
//Compare degrees;
      d=-1;
      //print("Per Grado");
     }
  if(deg(P.h)==deg(Q.h))
     {
      if(P.h==Q.h)
         {
          if(P.t==Q.t)
              {
//head=tail
               d=0;
               //print("Uguali");
              }
         }
     else
        {
//print(Minimus(variables(P.h/gcdMon(P.h,Q.h))));
//print(Minimus(variables(Q.h/gcdMon(P.h,Q.h))));
          if(Minimus(variables(P.h/gcdMon(P.h,Q.h)))<Minimus(variables(Q.h/gcdMon(P.h,Q.h))))
             {
             d=-1;
            //print("Per Indice");
             }
        }
     }
 return(d);
}
example
{ "EXAMPLE:"; echo = 2;
 ring r=0, (x,y,z), rp;
jmp p1;
p1.h=poly(1);
p1.t=poly(1);
jmp p2;
p2.h=x^2;
p2.t=poly(0);
jmp p3;
p3.h=x;
p3.t=poly(0);
 GJmpMins(p1, p2);
 GJmpMins(p2, p3);
GJmpMins(p1,p1);
}
////////////////////////////////////////////////////////////////////
proc TernCompare(list A, list B, list G)
"USAGE:    TernCompare(A,B,C); A list, B list, G list
RETURN:   int: d
NOTE:     A and B are terns, while G is the given list of
J-marked polynomials.
EXAMPLE:  example TernCompare; shows an example"
{
int d=-1;
//Start: A<B
if(A[1]==B[1])
  {
   if(A[2]==B[2]&& A[3]==B[3])
     {
      //print("Uguali");
      d=0;
     }
   else
     {
jmp g1=G[A[2]][A[3]];
jmp g2=G[B[2]][B[3]];
       if(GJmpMins(g1, g2)==1)
          {
            //print("Maggiore per il G");
            d=1;
          }
     }
  }
else
  {
    if(A[1]>B[1])
      {
//the ordering MUST be rp
        //print("Maggiore per Lex");
        d=1;
      }
  }
return(d);
}
example
{ "EXAMPLE:"; echo = 2;
 ring r=0, (x,y,z), rp;
jmp r1;
r1.h=z^3;
r1.t=poly(0);
jmp r2;
r2.h=z^2*y;
r2.t=poly(0);
jmp r3;
r3.h=z*y^2 ;
r3.t=-x^2*y;
jmp r4;
r4.h=y^5;
r4.t=poly(0);
list G2F=list(list(r1,r2,r3),list(r4));
TernCompare([1,1,1],[x,1,1],G2F);
}
////////////////////////////////////////////////////////////////////
proc MinOfV(list V, list G)
"USAGE:    Minimal(V,G); V list, G list
RETURN:   int: R
NOTE:     Input=lista(terne), G.
EXAMPLE:  example Minimal; shows an example"
{
//Minimal element for a given degree
list R=list();
list MIN=V[1];
int h=1;
int i;
for(i=2; i<=size(V); i++)
    {
//I consider the first as minimum
//If I find something smaller I change minimum
     if(TernCompare(V[i],MIN,G)<=0)
       {
        MIN=V[i];
        h=i;
       }
    }
//Return: [minimum,position of the minimum]
R=MIN,h;
return(R);
}
example
{ "EXAMPLE:"; echo = 2;
 ring r=0, (x,y,z), rp;
jmp r1;
r1.h=z^3;
r1.t=poly(0);
jmp r2;
r2.h=z^2*y;
r2.t=poly(0);
jmp r3;
r3.h=z*y^2 ;
r3.t=-x^2*y;
jmp r4;
r4.h=y^5;
r4.t=poly(0);
list G2F=list(list(r1,r2,r3),list(r4));
MinOfV(VConst(G2F,4,basering)[1],G2F);
}
////////////////////////////////////////////////////////////////////
proc OrderingV(list V,list G,list R)
"USAGE:   OrderingV(V,G,R); V list, G list, R list
RETURN:   list: R
NOTE:     Input: Vm,G,emptylist
EXAMPLE:  example OrderingV; shows an example"
{
//Order V[m]
//R  will contain results but at the beginning it is empty
list M=list();
if(size(V)==1)
  {
    R=insert(R,V[1],size(R));
  }
else
  {
   M=MinOfV(V,G);
   R=insert(R,M[1],size(R));
   V=delete(V,M[2]);
//recursive call
   R=OrderingV(V,G,R);
  }
return(R);
}
example
{ "EXAMPLE:"; echo = 2;
 ring r=0, (x,y,z), rp;
jmp r1;
r1.h=z^3;
r1.t=poly(0);
jmp r2;
r2.h=z^2*y;
r2.t=poly(0);
jmp r3;
r3.h=z*y^2;
r3.t=-x^2*y;
jmp r4;
r4.h=y^5;
r4.t=poly(0);
list G2F=list(list(r1,r2,r3),list(r4));
OrderingV(VConst(G2F,4,basering)[1],G2F,list());
}
////////////////////////////////////////////////////////////////////
proc StartOrderingV(list V,list G)
"USAGE:   StartOrdina(V,G); V list, G list
RETURN:   list: R
NOTE:     Input Vm,G. This procedure uses OrderingV to get
the ordered polynomials as in [BCLR].
EXAMPLE:  example StartOrderingV; shows an example"
{
 return(OrderingV(V,G, list()));
}
example
{ "EXAMPLE:"; echo = 2;
 ring r=0, (x,y,z), rp;
jmp r1;
r1.h=z^3;
r1.t=poly(0);
jmp r2;
r2.h=z^2*y;
r2.t=poly(0);
jmp r3;
r3.h=z*y^2;
r3.t=-x^2*y;
jmp r4;
r4.h=y^5;
r4.t=poly(0);
list G2F=list(list(r1,r2,r3),list(r4));
StartOrderingV(VConst(G2F,4,basering)[1],G2F);
}
////////////////////////////////////////////////////////////////////
proc Multiply(list L, list G)
"USAGE:    moltiplica(L,G); L list, G list
RETURN:   jmp: K
NOTE:     Input: a 3-ple,G. It performs the product associated
to the 3-uple.
EXAMPLE:  example Multiply; shows an example"
{
jmp g=G[L[2]][L[3]];
jmp K;
K.h=L[1]*g.h;
K.t=L[1]*g.t;
 return(K);
}
example
{ "EXAMPLE:"; echo = 2;
 ring r=0, (x,y,z), rp;
 list P=x^2,1,1;
jmp r1;
r1.h=z^3;
r1.t=poly(0);
jmp r2;
r2.h=z^2*y;
r2.t=poly(0);
jmp r3;
r3.h=z*y^2 ;
r3.t=-x^2*y;
jmp r4;
r4.h=y^5;
r4.t=poly(0);
list G2F=list(list(r1,r2,r3),list(r4));
Multiply(P,G2F);
}
////////////////////////////////////////////////////////////////////
proc IdealOfV(list V)
"USAGE:    IdealOfV(V); V list
RETURN:   ideal: I
NOTES: this procedure takes a list of Vm's of a certain degree
and construct their ideal, multiplying the head by the weighted
variable t.
EXAMPLE:  example IdealOfV; shows an example"
{
ideal I=0;
int i;
if (size(V)!=0)
  {
   list M=list();
jmp g;
   for(i=1; i<= size(V); i++)
       {
         g=V[i];
         g.h=t*g.h;
         M[i]=g.h+g.t;
       }
   I=M[1..size(M)];
//print("IdealOfV");
  //I=std(I);
  }
return(I);
}
example
{ "EXAMPLE:"; echo = 2;
 ring r=0, (x,y,z,t), rp;
jmp r1;
r1.h=z^3;
r1.t=poly(0);
jmp r2;
r2.h=z^2*y;
r2.t=poly(0);
jmp r3;
r3.h=z*y^2 ;
r3.t=-x^2*y;
jmp r4;
r4.h=y^5;
r4.t=poly(0);
list G2F=list(list(r1,r2,r3),list(r4));
IdealOfV(G2F[1]);
}
////////////////////////////////////////////////////////////////////
proc NewWeight(int n)
"USAGE:    NewWeight(n); n int
RETURN:   intvec: u
EXAMPLE:  example NewWeight; shows an example"
{
intvec u=0;
u[n]=1;
return(u);
}
example
{ "EXAMPLE:"; echo = 2;
 NewWeight(3);
}
////////////////////////////////////////////////////////////////////
proc FinalVm(list V1 , list G1 ,def r)
"USAGE:     FinalVm(V1, G1, r);  V1 list,  G1 list , r
RETURN:   intvec: u
EXAMPLE:  example NewWeight; shows an example"
{
//multiply and reduce, degree by degree
intvec u=NewWeight(nvars(r)+1);
list L=ringlist(r);
L[2]=insert(L[2],"t",size(L[2]));
//print(L[2]);
list ordlist="a",u;
L[3]=insert(L[3],ordlist,0);
def H=ring(L);
//print(V1);
//print(G1);
list M=list();
jmp p;
list N;
poly q;
poly s;
int i;
int j;
for(i=1; i<=size(G1); i++)
   {
           N=list();
           for(j=1; j<=size(G1[i]); j++)
              {
                p=G1[i][j];
                q=p.h;
                s=p.t;
                N[j]=list(q,s);
               }
           M[i]=N;
    }
p.h=poly(0);
p.t=poly(0);
setring H;
list R=list();
list S=list();
//print("anello definito");
def V=imap(r,V1);
//def G=imap(r,G1);
//print(V);
def MM=imap(r,M);
list G=list();
list N=list();
for(i=1; i<=size(MM); i++)
   {
           for(j=1; j<=size(MM[i]); j++)
              {
                p.h=MM[i][j][1];
                p.t=MM[i][j][2];
                N[j]=p;
               }
           G[i]=N;
    }
ideal I=0;
jmp LL;
jmp UU;
 for(i=1; i<=size(V);i++)
    {
       R[i]=list();
       S[i]=list();
       I=0;
       for(j=1;j<=size(V[i]); j++)
          {
            LL=Multiply(V[i][j],G);
            LL.t=reduce(t*LL.t,I);
//I only reduce the tail
              LL.t=subst(LL.t,t,1);
              S[i]=insert(S[i],LL,size(S[i]));
              LL.h=t*LL.h;
            R[i]=insert(R[i],LL,size(R[i]));
             UU=R[i][j];
              I=I+ideal(UU.h+UU.t);
              attrib(I,"isSB",1);
          }
    }
list M=list();
poly q;
poly s;
for(i=1; i<=size(S); i++)
   {
           N=list();
           for(j=1; j<=size(S[i]); j++)
              {
                p=S[i][j];
                q=p.h;
                s=p.t;
                N[j]=list(q,s);
               }
           M[i]=N;
    }
p.h=poly(0);
p.t=poly(0);
setring r;
def MM=imap(H,M);
list MMM=list();
for(i=1; i<=size(MM); i++)
   {
           N=list();
           for(j=1; j<=size(MM[i]); j++)
              {
                p.h=MM[i][j][1];
                p.t=MM[i][j][2];
                N[j]=p;
               }
           MMM[i]=N;
    }
return(MMM);
}
example
{ "EXAMPLE:"; echo = 2;
 ring r=0, (x,y,z), rp;
jmp r1;
r1.h=z^3;
r1.t=poly(0);
jmp r2;
r2.h=z^2*y;
r2.t=poly(0);
jmp r3;
r3.h=z*y^2 ;
r3.t=-x^2*y;
jmp r4;
r4.h=y^5;
r4.t=poly(0);
list G2F=list(list(r1,r2,r3),list(r4));
 FinalVm(VConst(G2F,6,r) , G2F, r);
}
////////////////////////////////////////////////////////////////////
proc ConstructorMain(list G, int c,def r)
"USAGE:    Costruttore(G,c); G list, c int
RETURN:   list: R
NOTE:     At the end separated by degree.
EXAMPLE:  example Costruttore; shows an example"
{
list V=list();
V= VConst(G,c);
//print("VConst");
//V non ordered
list L=list();
list R=list();
int i;
// head, position
//order the different degrees
for(i=1; i<=size(V); i++)
   {
    L[i]=StartOrderingV(V[i], G);
   }
//multiply and reduce
//print("Ordinare");
R=FinalVm(L, G, r);
//print("FinalVm");
return(R);
}
example
{ "EXAMPLE:"; echo = 2;
 ring r=0, (x,y,z), rp;
jmp r1;
r1.h=z^3;
r1.t=poly(0);
jmp r2;
r2.h=z^2*y;
r2.t=poly(0);
jmp r3;
r3.h=z*y^2 ;
r3.t=-x^2*y;
jmp r4;
r4.h=y^5;
r4.t=poly(0);
list G2F=list(list(r1,r2,r3),list(r4));
ConstructorMain(G2F,6,r);
}
////////////////////////////////////////////////////////////////////
proc EKCouples(jmp A, jmp B)
"USAGE:    CoppiaEK(A,B); A list, B list
RETURN:   list: L
NOTE:     At the end the monomials involved by EK.
EXAMPLE:  example EKCouples; shows an example"
{
poly E;
list L=0,0;
string s=varstr(basering);
list VVV=varstr(basering);
//L will contain results
poly h=Minimus(variables(A.h));
//print(h);
int l=findvars(h,1)[2][1];
if(l!=nvars(basering))
 {
//print("vero");
//print(l);
  for(int j=l+1;j<=nvars(basering); j++)
   {
    //print("entrata");
    //print(var(j));
    E=var(j)*A.h/B.h;
//Candidate for * product
    //print(E);
    if(E!=0)
      {
        //print("primo if passato");
        if(Minimus(variables(B.h))>=Maximus(variables(E)))
           {
//Does it work with * ?
            //print("secondo if passato");
            L[1]=j;
            L[2]=E;
            break;
           }
      }
   }
  }
return (L);
}
example
{ "EXAMPLE:"; echo = 2;
 ring r=0, (x,y,z), rp;
jmp A;
A.h=y*z^2;
A.t=poly(0);
jmp B;
B.h=y^2*z;
B.t=poly(0);
EKCouples(A,B);
EKCouples(B,A);
}
////////////////////////////////////////////////////////////////////
proc EKPolys(list G)
"USAGE:    PolysEK(G); G list
RETURN:   list: EK, list: D
NOTE:     At the end EK polynomials and their degrees

EXAMPLE:  example PolysEK; shows an example"
{
list D=list();
list C=list();
list N=0,0;
list EK=list();
int i;
int j;
int k;
int l;
jmp p;
for(i=1; i<=size(G); i++)
   {
     for(j=1; j<=size(G[i]); j++)
        {
         for(k=1; k<=size(G); k++)
             {
               for(l=1; l<=size(G[k]); l++)
                  {
                     if(i!=k||j!=l)
                       {
//Loop on polynomials
                        C=EKCouples(G[i][j], G[k][l]);
//print("coppia");
                        if(C[2]!=0)
                          {
                           C=insert(C,list(i,j,k,l),size(C));
                           EK=insert(EK,C,size(EK));
                           p=G[k][l];
                           D=insert(D,deg(C[2]*p.h),size(D));
                          }
                       }
                  }
             }
        }
   }
//Double Return
return(EK, D);
}
example
{ "EXAMPLE:"; echo = 2;
  ring r=0, (x,y,z), rp;
jmp r1;
r1.h=z^3;
r1.t=poly(0);
jmp r2;
r2.h=z^2*y;
r2.t=poly(0);
jmp r3;
r3.h=z*y^2;
r3.t=-x^2*y;
jmp r4;
r4.h=y^5;
r4.t=poly(0);
list G2F=list(list(r1,r2,r3),list(r4));
EKPolys(G2F);
}
////////////////////////////////////////////////////////////////////
proc EKPolynomials(list EK, list G)
"USAGE:     EKPolynomials(EK,G); EK list, G list
RETURN:   list: p
NOTE:     At the end I obtain the EK polynomials and
their degrees.
EXAMPLE:  example SpolyEK; shows an example"
{
jmp u=G[EK[3][1]][EK[3][2]];
jmp q=G[EK[3][3]][EK[3][4]];
return(var(EK[1])*(u.h+u.t)-EK[2]*(q.h+q.t));
}
example
{ "EXAMPLE:"; echo = 2;
 ring r=0, (x,y,z), rp;
jmp r1;
r1.h=z^3;
r1.t=poly(0);
jmp r2;
r2.h=z^2*y;
r2.t=poly(0);
jmp r3;
r3.h=z*y^2;
r3.t=-x^2*y;
jmp r4;
r4.h=y^5;
r4.t=poly(0);
list G2F=list(list(r1,r2,r3),list(r4));
list EK,D=EKPolys(G2F);
EKPolynomials(EK[1],G2F);
}
////////////////////////////////////////////////////////////////////
proc TestJMark(list G1,def r)
"USAGE:    TestJMark(G);  G list
RETURN:    int: i
NOTE:
This procedure performs J-marked basis test.@*
The input is a list of J-marked polynomials (jmp) arranged
by degree, so G1 is a list of list.@*
The output is a boolean evaluation:
True=1/False=0
EXAMPLE:  example TestJMark; shows an example"
{int flag=1;
if(size(G1)==1 && size(G1[1])==1)
 {
  //Hypersurface
  print("Only One Polynomial");
  flag=1;
 }
else
  {
   int d=0;
   list EK,D=EKPolys(G1);
//print("PolysEK");
   //I found EK couples
   int massimo=Max(D);
   list V1=ConstructorMain(G1,massimo,r);
//print("Costruttore");
//print(V1);
   jmp mi=V1[1][1];
   int minimo=Min(deg(mi.h));
   intvec u=NewWeight(nvars(r)+1);
list L=ringlist(r);
L[2]=insert(L[2],"t",size(L[2]));
//print(L[2]);
list ordlist="a",u;
L[3]=insert(L[3],ordlist,0);
def H=ring(L);
list JJ=list();
jmp pp;
jmp qq;
int i;
int j;
list NN;
for(i=size(V1);i>0;i--)
    {
     NN=list();
     for(j=size(V1[i]);j>0;j--)
         {
          //print(j);
          pp=V1[i][j];
          NN[j]=list(pp.h,pp.t);
          }
//print(NN);
JJ[i]=NN;
//print(JJ[i]);
//print(i);
    }
//print(JJ);
list KK=list();
list UU=list();
//jmp qq;
for(i=size(G1);i>0;i--)
    {
     for(j=size(G1[i]);j>0;j--)
         {
          //print(j);
          qq=G1[i][j];
          UU[j]=list(qq.h,qq.t);
          }
//print(UU);
KK[i]=UU;
    }
setring H;
//I defined the new ring with the weighted
//variable t
poly p;
//print("anello definito");
def JJJ=imap(r,JJ);
def EK=imap(r,EK);
//print(flag);
//imap(r,D);
list V=list();
jmp fp;
//int i;
//int j;
list N;
for(i=size(JJJ); i>0; i--)
   {
           N=list();
           for(j=size(JJJ[i]); j>0; j--)
              {
                fp.h=JJJ[i][j][1];
                fp.t=JJJ[i][j][2];
                N[j]=fp;
               }
           V[i]=N;
            }
//print(V);
def KKJ=imap(r,KK);
list G=list();
list U=list();
for(i=1; i<=size(KKJ); i++)
   {
           for(j=1; j<=size(KKJ[i]); j++)
              {
                fp.h=KKJ[i][j][1];
                fp.t=KKJ[i][j][2];
                U[j]=fp;
               }
           G[i]=U;
    }
// print(V);
//print(G);
//I imported in H everithing I need
poly q;
ideal I;
   for(j=1; j<=size(EK);j++)
      {
       d=D[j];
       p=EKPolynomials(EK[j],G);
       //print("arrivo");
       I=IdealOfV(V[d-minimo+1]);
attrib(I,"isSB",1);
//print(I);
q=reduce(t*p,I);
//print(I[1]);
//print(t*p);
q=subst(q,t,1);
//I reduce all the EK polynomials
//       q=RiduzPoly(V[d-minimo+1], p);
       if(q!=0)
         {
//check whether reduction is 0
          print("NOT A BASIS");
         flag=0;
          break;
         }
     }
  }
//print(flag);
setring r;
//typeof(flag);
return(flag);
}
example
{ "EXAMPLE:"; echo = 2;
 ring r=0, (x,y,z), rp;
jmp r1;
r1.h=z^3;
r1.t=poly(0);
jmp r2;
r2.h=z^2*y;
r2.t=poly(0);
jmp r3;
r3.h=z*y^2 ;
r3.t=-x^2*y;
jmp r4;
r4.h=y^5;
r4.t=poly(0);
list G2F=list(list(r1,r2,r3),list(r4));
TestJMark(G2F,r);
}