hggroeb.red 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. module hggroeb; % Homogeneous Graded Grobner bases.
  2. % Buchberger algorithm for homogeneous graded polynomial
  3. % systems. d1 and d2 are positive integers (d2 may be
  4. % infinity). Compute the basis for the sectin [d1,d2].
  5. %
  6. % see Becker-Weispfenning, Chapter 10.
  7. %
  8. % A local redefinition of the function groebspolynom is
  9. % used to exclude pairs which do not fit into the grade interval.
  10. fluid '(dd!-1!*, dd!-2!*);
  11. % imported fluids.
  12. fluid '(dipsortmode!* !*vdpinteger !*vdpmodular !*groebprot
  13. !*gltbasis pcount!*);
  14. global '(groebprotfile gltb gvarslast);
  15. symbolic procedure dd_groebner!* q;
  16. (begin scalar vars,w,np,oldorder,!*redefmsg;
  17. integer pcount!*;
  18. w := for each j in groerevlist u
  19. collect if eqexpr j then !*eqn2a j else j;
  20. vars := groebnervars(w,nil);
  21. if null vars then rerror(groebner,4,"Empty system Groebner");
  22. groedomainmode();
  23. oldorder := vdpinit vars;
  24. % cancel common denominators
  25. w := for each j in w collect f2vdp numr simp j;
  26. dd_homog!-check w;
  27. if not !*vdpInteger then
  28. <<np := t;
  29. for each p in w do
  30. np := if np then vdpCoeffcientsFromDomain!? p else nil;
  31. if not np then <<!*vdpModular:= nil; !*vdpinteger := T>>;
  32. >>;
  33. if !*groebprot then <<groebprotfile := '(list)>>;
  34. w := dd!-bbg(w);
  35. if !*gltbasis then
  36. gltb :=
  37. 'list . for each base in w collect
  38. 'list . for each j in base collect
  39. vdp2a vdpfmon(a2vbc 1,vdpevlmon j);
  40. w := 'list . for each j in w collect vdp2a j;
  41. vdpcleanup();
  42. gvarslast := 'list . vars;
  43. return w;
  44. end)
  45. where dd!-1!*=ieval car q,
  46. dd!-2!*=reval cadr q,
  47. u=reval caddr q;
  48. put('dd_groebner,'psopfn,'dd_groebner!*);
  49. put('dd_groebner,'number!-of!-args,3);
  50. symbolic procedure dd!-bbg w;
  51. begin scalar r;
  52. copyd('groebspolynom,'dd!-groebspolynom);
  53. r:=errorset({'groebner2,mkquote w,nil},t,nil);
  54. copyd('groebspolynom,'true!-groebspolynom);
  55. if errorp r then rederr "dd_groebner failed";
  56. return caar r;
  57. end;
  58. symbolic procedure dd_homog!-check w;
  59. begin scalar d,q,tst,q;
  60. if not memq(dipsortmode!*,'(graded weighted gradlex revgradlex))
  61. then typerr(dipsortmode!*,"term order for dd_groebner");
  62. for each p in w do
  63. <<q:=p; p:=vdppoly p;
  64. d:=ev!-gamma(dipevlmon p); p:=dipmred p;
  65. while not dipzero!? p do
  66. <<tst:=tst or d neq ev!-gamma(dipevlmon p); p:=dipmred p>>;
  67. if tst then typerr(vdp2a q,"homogeneous polynomial");
  68. >>;
  69. end;
  70. copyd('true!-groebspolynom,'groebspolynom);
  71. symbolic procedure dd!-groebspolynom(p1,p2);
  72. (if (dd!-1!* <= d and (dd!-2!*='infinity or d <= dd!-2!*)) then
  73. true!-groebspolynom(p1,p2) else a2vdp 0)
  74. where d=ev!-gamma vevlcm(vdpevlmon p1, vdpevlmon p2);
  75. endmodule;
  76. end;