groeweak.red 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. module groeweak;% Weak test for f ~ 0 modulo g .
  2. switch groebweak;
  3. symbolic procedure groebweakzerotest(f,g,type);
  4. % Test f == 0 modulo g with ON MODULAR .
  5. begin scalar f1,c,vev,divisor,oldmode,a;
  6. if vdpzero!? f then return f;
  7. if current!-modulus = 1 then setmod list 2097143;
  8. oldmode:=setdmode(' modular,t);
  9. f:=groebvdp2mod f;
  10. f1:=vdpzero();a:=vbcfi 1;
  11. while not vdpzero!? f and vdpzero!? f1 do
  12. begin
  13. vev:=vdpevlmon f;c:=vdpLbc f;
  14. if type = 'sort then while g and vevcompless!?(vev,vdpevlmon(car g))
  15. do g:=cdr g;
  16. divisor:=groebsearchinlist(vev,g);
  17. if divisor and !*trgroebs then
  18. <<prin2 "//m-";prin2 vdpnumber divisor>>;
  19. if divisor then
  20. if vdplength divisor = 1 then f:=vdpcancelmvev(f,vdpevlmon divisor)
  21. else <<divisor:=groebvdp2mod divisor;
  22. if divisor then f:=groebreduceonesteprat(f,nil,c,vev,divisor)
  23. else f1:=f>>
  24. else f1:=f end;
  25. if not vdpzero!? f1 and !*trgroebs then
  26. <<prin2t " - nonzero result in modular reduction:";vdpprint f1>>;
  27. setdmode(' modular,nil);
  28. if oldmode then setdmode(get(oldmode,' dname), t);
  29. return vdpzero!? f1 end;
  30. symbolic procedure groebweaktestbranch!=1(poly,g,d);
  31. % Test gb(g)== { 1 } in modular style .
  32. groebweakbasistest({ poly },g,d);
  33. symbolic procedure groebweakbasistest(g0,g,d);
  34. begin scalar oldmode,d,d1,d2,p,p1,s,h;
  35. scalar !*vdpinteger; % Switch to field type calclulation .
  36. return nil;
  37. if not !*groebfac then return nil;
  38. if current!-modulus= 1 then setmod { 2097143 };
  39. if !*trgroeb then
  40. prin2t "---------------- modular test of branch ------";
  41. oldmode:=setdmode(' modular,t);
  42. g0:=for each p in g0 collect groebvdp2mod p;
  43. g:=for each p in g collect groebvdp2mod p;
  44. d:=for each p in d collect { car p,
  45. groebvdp2mod cadr p,groebvdp2mod caddr p };
  46. while d or g0 do
  47. begin if g0 then
  48. << % Take next poly from input .
  49. h:=car g0;g0:=cdr g0;p:={ nil,h,h }>>
  50. else
  51. << % Take next poly from pairs .
  52. p:=car d;d:=delete(p,d);
  53. s:=groebspolynom(cadr p,caddr p);
  54. h:=groebsimpcontnormalform groebnormalform(s,g,' sort);
  55. if vdpzero!? h then !*trgroeb and groebmess4(p,d)>>;
  56. if vdpzero!? h then
  57. <<pairsdone!*:=( vdpnumber cadr p . vdpnumber caddr p). pairsdone!*;
  58. go to bott>>;
  59. if vevzero!? vdpevlmon h then % Base 1 found .
  60. << !*trgroeb and groebmess5(p,h);goto stop>>;
  61. s:=nil;
  62. h:=vdpenumerate h;!*trgroeb and groebmess5(p,h);
  63. % Construct new critical pairs .
  64. d1:=nil;
  65. for each f in g do
  66. <<d1:=groebcplistsortin({ tt(f,h),f,h },d1);
  67. if tt(f,h)= vdpevlmon f then
  68. <<g:=delete(f,g);
  69. !*trgroeb and groebmess2 f>>>>;
  70. !*trgroeb and groebmess51 d1;
  71. d2:=nil;
  72. while d1 do
  73. <<d1:=groebinvokecritf d1;
  74. p1:=car d1;d1:=cdr d1;
  75. d2:=groebinvokecritbuch4(p1,d2);d1:=groebinvokecritm(p1,d1)>>;
  76. d:=groebinvokecritb(h,d);d:=groebcplistmerge(d,d2);g:=h . g;
  77. go to bott;
  78. stop: d:=g:=g0:=nil;
  79. bott: end;
  80. if !*trgroeb and null g then
  81. prin2t "**** modular test detects empty branch!";
  82. if !*trgroeb then
  83. prin2t "------ end of modular test of branch ------";
  84. setdmode(' modular,nil);
  85. if oldmode then setdmode(get(oldmode,' dname), t);
  86. return null g end;
  87. fluid '(!*localtest);
  88. symbolic procedure groebfasttest(g0,g,d,g99);
  89. if !*localtest then
  90. <<!*localtest:=nil;g99:=nil;groebweakbasistest(g0,g,d)>>
  91. else if !*groebweak and g and vdpunivariate!? car g
  92. then groebweakbasistest(g0,g,d);
  93. symbolic procedure groebvdp2mod f;
  94. % Convert a vdp in modular form;in case of headterm loss,nil is returned .
  95. begin scalar u,c,mf;
  96. u:=vdpgetprop(f,' modimage);
  97. if u then return if u = ' nasty then nil else u;
  98. mf:=vdpresimp f;
  99. if !*gsugar then vdpputprop(mf,' sugar,vdpgetprop(f,' sugar));
  100. c:=errorset!*( { ' vbcinv,mkquote vdplbc mf },nil);
  101. if not pairp c then
  102. <<prin2t "************** nasty module(loss of headterm) ****";
  103. print f;print u;vdpprint f;vdpprint u;
  104. vdpputprop(f,' modimage,' nasty);return nil>>;
  105. u:=vdpvbcprod(mf,car c);
  106. vdpputprop(u,' number,vdpgetprop(f,' number));
  107. vdpputprop(f,' modimage,u);
  108. if !*gsugar then vdpputprop(u,' sugar,vdpgetprop(f,' sugar));
  109. return u end;
  110. symbolic procedure groebmodeval(f,break);
  111. % Evaluate LISP form r with REDUCE modular domain .
  112. begin scalar oldmode,a,!*vdpinteger,groebmodular!*;
  113. groebmodular!*:=t;break:=nil;
  114. if current!-modulus = 1 then setmod list 2097143;
  115. oldmode:=setdmode(' modular,t);
  116. a:=errorset!*(f,t);
  117. setdmode(' modular,nil);
  118. if oldmode then setdmode(get(oldmode,' dname), t);
  119. return if atom a then nil else car a end;
  120. endmodule;;end;