groeweak.red 6.3 KB

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