groebsor.red 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. module groebsor;
  2. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  3. %
  4. % maintenance of lists of critical pairs (sorting etc.)
  5. %
  6. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  7. symbolic procedure groebcplistsortin (p,pl);
  8. % Distributive polynomial critical pair list sort. pl is a
  9. % special list for Groebner calculation, p is a pair.
  10. % returns the updated list pl (p sorted into);
  11. if null pl then list p
  12. else
  13. <<groebcplistsortin1 (p,pl); pl>>;
  14. symbolic procedure groebcplistsortin1(p,pl);
  15. % destructive insert of p into nonnull pl
  16. if not groebcpcompless!?(car pl, p)
  17. then <<rplacd(pl,car pl . cdr pl); rplaca(pl,p)>>
  18. else
  19. if null cdr pl then rplacd(pl,list p)
  20. else
  21. groebcplistsortin1(p,cdr pl);
  22. symbolic procedure groebcplistsort g;
  23. <<for each p in g do gg:=groebcplistsortin(p,gg); gg>>
  24. where gg=nil;
  25. symbolic procedure groebcplistmerge(pl1,pl2);
  26. % Distributive polynomial critical pair list merge. pl1 and pl2
  27. % are critical pair lists used in the Groebner calculation.
  28. % groebcplistmerge(pl1,pl2) returns the merged list.
  29. begin scalar cpl1,cpl2,sl;
  30. if null pl1 then return pl2;
  31. if null pl2 then return pl1;
  32. cpl1 := car pl1; cpl2 := car pl2;
  33. sl := groebcpcompless!?(cpl1, cpl2);
  34. return
  35. (if sl then cpl1 . groebcplistmerge(cdr pl1,pl2)
  36. else cpl2 . groebcplistmerge(pl1,cdr pl2) )
  37. end;
  38. symbolic procedure groebcpcompless!?(p1,p2);
  39. % compare 2 pairs srt their sugar(=cadddr) or their lcm (=car).
  40. if !*gsugar then
  41. (if not(d=0) then d<0 else
  42. if not(q=0) then q<0 else
  43. vdpnumber(caddr p1)<vdpnumber(caddr p2)
  44. ) where d= cadddr p1 - cadddr p2, q=vevcomp(car p1,car p2)
  45. else vevcompless!?(car p1,car p2);
  46. endmodule;
  47. end;