groebcri.red 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. module groebcri;
  2. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  3. %
  4. % criteria for the Buchberger algorithm
  5. %
  6. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  7. fluid '(Bcount!* B4count!* Mcount!* Fcount!*);
  8. smacro procedure tt(s1,s2);
  9. % lcm of leading terms of s1 and s2
  10. vevlcm(vdpevlmon s1,vdpevlmon s2);
  11. smacro procedure atleast2elementsin (u);
  12. % test if u has at least a cadr element
  13. u and cdr u;
  14. symbolic procedure groebbuchcrit4(p1,p2,e);
  15. % Buchberger criterion 4. p1 and p2 are distributive
  16. % polynomials. e is the least common multiple of
  17. % the leading exponent vectors of the distributive
  18. % polynomials p1 and p2. groebBuchcrit4(p1,p2,e) returns a
  19. % boolean expression. True if the reduction of the
  20. % distributive polynomials p1 and p2 is necessary
  21. % else false.
  22. % orig:
  23. % e neq vevsum( vdpevlmon p1, vdpevlmon p2);
  24. groebbuchcrit4t(vdpevlmon p1,vdpevlmon p2);
  25. symbolic procedure groebbuchcrit4t(e1,e2);
  26. % nonconstructive test of lcm(e1,e2) = e1 + e2
  27. % equivalent: no matches of nonzero elements.
  28. if null e1 or null e2 then nil
  29. else
  30. if (car e1 neq 0) and (car e2 neq 0) then t
  31. else groebbuchcrit4t(cdr e1,cdr e2);
  32. symbolic procedure groebinvokecritbuch4 (p,d2);
  33. % Buchberger's criterion 4 is tested on the pair p and the list
  34. % D2 of critical pairs is updated with respect to that crit.
  35. % Result is the updated D2;
  36. begin scalar p1,p2,vev1,vev2,f1,f2,fd,b4;
  37. p1 := cadr p;
  38. p2 := caddr p;
  39. vev1 := vdpevlmon p1;
  40. vev2 := vdpevlmon p2;
  41. f1 := vdpGetProp(p1,'monfac);
  42. f2 := vdpGetProp(p2,'monfac);
  43. % discard known common factors first
  44. if f1 and f2 then
  45. <<fd := vevmin (f1,f2);
  46. b4 := groebbuchcrit4t(vevdif(vev1,fd),vevdif(vev2,fd));
  47. if b4 and % is the body itself a common factor?
  48. vevdif(vev1,f1) = vevdif(vev2,f2)
  49. % test if the polys reduced by their monom.
  50. % factor are equal
  51. and groebbuchcrit4compatible(p1,f1,p2,f2)
  52. then b4 := nil;
  53. >>
  54. else
  55. b4 := groebbuchcrit4t(vev1,vev2);
  56. if b4 then
  57. d2 := append (d2, list p)
  58. else
  59. b4count!* := b4count!* + 1;
  60. return d2;
  61. end;
  62. symbolic procedure groebbuchcrit4compatible (p1,f1,p2,f2);
  63. % p1,p2 polys, f1,f2 exponent vectors (monomials), which are known to
  64. % be factors of their f;
  65. % tests, if p1/f1 = p2/f2
  66. if vdpzero!? p1 then vdpzero!? p2
  67. else
  68. if vdplbc p1 = vdplbc p2 and
  69. groebbuchcrit4compatiblevev(vdpevlmon p1,f1,vdpevlmon p2,f2)
  70. then groebbuchcrit4compatible (vdpred p1,f1,vdpred p2,f2)
  71. else nil;
  72. symbolic procedure groebbuchcrit4compatiblevev (vev1,f1,vev2,f2);
  73. if null vev1 then null vev2 else
  74. if (if f1 then car vev1 - car f1 else car vev1)
  75. =
  76. (if f2 then car vev2 - car f2 else car vev2)
  77. then
  78. groebbuchcrit4compatiblevev (cdr vev1,
  79. if f1 then cdr f1 else nil,
  80. cdr vev2,
  81. if f2 then cdr f2 else nil)
  82. else nil;
  83. symbolic procedure groebinvokecritf d1;
  84. % groebInvokeCritF tests a list D1 of critical pairs. It cancels all
  85. % critical pairs but one in D1 having the same lcm (i.e. car
  86. % component) as car(D1). This only one is chosen, if possible,
  87. % such that it doesn't satisfy groebBuchcrit4.
  88. % Version: moeller upgraded 5.7.87
  89. begin scalar tp1,p2,active;
  90. tp1 := car(car(d1));
  91. active := atLeast2elementsin d1;
  92. while active do
  93. << p2 := cadr d1;
  94. if car(p2) = tp1 then
  95. << fcount!* := fcount!* +1;
  96. if not groebbuchcrit4t(cadr p2, caddr p2)
  97. then d1 := cdr(d1)
  98. else d1 := groedeletip(p2,d1);
  99. active := atleast2elementsin d1 >>
  100. else active := nil >>;
  101. return d1;
  102. end;
  103. symbolic procedure groebinvokecritm (p1,d1);
  104. % D1 is a list of critical pairs, p1 is a critical pair.
  105. % crit M tests, if the lcm of p1 divides one of the lcm's in D1.
  106. % If so, this object is eliminated.
  107. % Result is the updated D1;
  108. << for each p3 in d1 do
  109. if buch!-vevdivides!?(car(p1), car(p3)) then
  110. <<mcount!* := mcount!*+1;
  111. d1 := groedeletip (p3,d1)>>; % Criterion M
  112. d1>>;
  113. symbolic procedure groebinvokecritb (fj,d);
  114. % D is a list of critical pairs, fj is a polynomial.
  115. % Crit B allows to eliminate a pair from D, if the leading monomial
  116. % of fj divides the lcm of the pair, but the lcm of fj with each of
  117. % the members of the pair is not the lcm of the pair itself
  118. % Result is the updated D;
  119. << for each p in d do
  120. if buch!-vevdivides!?(vdpevlmon(fj), car(p)) and
  121. tt(fj,cadr(p)) neq car(p) and % Criterion B
  122. tt(fj,caddr(p)) neq car(p) then
  123. <<bcount!* := bcount!* +1;
  124. d:= delete (p,d)>>;
  125. d>>;
  126. endmodule;
  127. end;