groebsea.red 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. module groebsea;
  2. % Support of search for reduction polynomials.
  3. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  4. %
  5. % Search for reduction candidates in a list.
  6. symbolic procedure groebsearchinlist(vev,g);
  7. % Search for a polynomial in the list 'g',such that the lcm divides
  8. % vev;'g' is expected to be sorted in descending sequence.
  9. if null g then nil
  10. else if buchvevdivides!?(vdpevlmon car g,vev)then car g
  11. else groebsearchinlist(vev,cdr g);
  12. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  13. %
  14. % Search list for polynomials;
  15. % simple variant: mapped to list.
  16. %
  17. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  18. symbolic procedure groeblistadd(poly,stru);
  19. % Add one polynomial to the tree;
  20. % if this is a simple polynomial(mono or bino), reform
  21. % the list.
  22. if hcount!* #< 5000 then vdplsortin(poly,stru)
  23. else vdplsortinreplacing(poly,stru);
  24. symbolic procedure groebstreeadd(poly,stru);
  25. % Map 'groebstreeadd' to 'groeblistadd'.
  26. groeblistadd(poly,stru);
  27. % symbolic procedure groeblistreconstruct u;
  28. % % Reconstructs a tree from a linear list of polynomials.
  29. % vdplsort u;
  30. symbolic procedure groebvevdivides!?(e1,e2);
  31. % Look, if 'e1' is a factor of 'e2'.
  32. if null e1 then t else if null e2 then(if vevzero!? e1 then t else nil)else
  33. if car e1 #> car e2 then nil else groebvevdivides!?(cdr e1,cdr e2);
  34. % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
  35. % Reforming g, d and g99 when a very simple polynomial was
  36. % found(e.g. a monomial, a binomial).
  37. symbolic procedure groebsecondaryreduction(poly,g,g99,d,gc,
  38. mode);
  39. % If poly is a simple polynomial, the polynomials in 'g' and 'g99'
  40. % are reduced in a second pass. Result is 'g',secondvalue is 'g99'.
  41. % 'mode' says, that 'g99' has to be modified in place.
  42. begin scalar break,first,p,pl,rep,rpoly,vev,x;
  43. mode:=nil;
  44. secondvalue!*:=g99;thirdvalue!*:=d;fourthvalue!*:=gc;
  45. vev:=vdpevlmon poly;rpoly:=vdpred poly;
  46. % Cancel redundant elements in 'g99'.
  47. for each p in g99 do if buchvevdivides!?(vev,vdpevlmon p)
  48. then g99:=delete(p,g99);
  49. if vdplength poly > 2 or vevzero!? vev then return g;
  50. if !*groebweak and not vdpzero!? rpoly
  51. and(groebweaktestbranch!=1(poly,g,d)) then return 'abort;
  52. !*trgroeb and groebmess50 g;
  53. pl:=union(g,g99);first:=t;
  54. while pl and not break do
  55. <<p:= car pl;pl:=cdr pl;
  56. if groebprofitsfromvev(p,vev)then
  57. % Replace by simplified version.
  58. <<x:=groebnormalform1(p,poly);
  59. x:=groebsimpcontnormalform x;x:=vdpenumerate x;
  60. if first then !*trgroeb and groebmess20(poly);
  61. first:=nil;!*trgroeb and groebmess21(p,x);
  62. rep:=( p.x).rep;
  63. if not vdpzero!? x and vevzero!? vdpevlmon x then break:=t;% 1 found.
  64. >>>>;
  65. if break then return 'abort;
  66. % Reform 'g99'.
  67. g99:=for each p in g99 collect groebsecondaryreplace(p,rep);
  68. secondvalue!*:= groebsecondaryremovemultiples g99;
  69. thirdvalue!*:=d;% Reform 'd'.
  70. fourthvalue!*:=groebsecondaryremovemultiples % Reform 'gc'.
  71. for each y in gc collect groebsecondaryreplace(y,rep);
  72. g:=for each y in g collect groebsecondaryreplace(y,rep);
  73. !*trgroeb and groebmess50 g;
  74. return groebsecondaryremovemultiples g end;
  75. symbolic procedure groebsecondaryremovemultiples g;
  76. if null g then nil else
  77. if vdpzero!? car g or member(car g,cdr g)then
  78. groebsecondaryremovemultiples cdr g else
  79. car g.groebsecondaryremovemultiples cdr g;
  80. symbolic procedure groebsecondaryreplace(x,rep);
  81. (if y then cdr y else x)where y=atsoc(x,rep);
  82. endmodule;;end;