groebrst.red 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. module groebrst;
  2. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  3. %
  4. % restrictions for polynomials during Groebner base calculation
  5. %
  6. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  7. symbolic procedure groebtestrestriction (h,arg);
  8. if groebrestriction!* = 'nonnegative then groebnonneg(h,arg)
  9. else
  10. if groebrestriction!* = 'positive then groebpos(h,arg)
  11. else
  12. if groebrestriction!* = 'izeropoint then groebzero(h,arg)
  13. else
  14. rerror(groebnr2,9,
  15. "Groebner: general restrictions not yet implemented");
  16. symbolic procedure groebnonneg(h,arg);
  17. % test if h is a polynomial which can have the value zero with
  18. % only nonnegative variable settings.
  19. begin scalar x,break,vev1,vevl,problems,problems1,r;
  20. if vdpzero!? h then return nil
  21. else
  22. if vevzero!? vdpevlmon h then goto finish;
  23. % first test the coefficients
  24. if vdpredZero!? h then return nil; % simple monomial
  25. break := nil;
  26. x := h;
  27. while not vdpzero!? x and not break do
  28. <<vev1 := vdpevlmon x;
  29. if not vbcplus!? vdpLbc x then break := t;
  30. if not break then x := vdpred x>>;
  31. if break then return nil; % at least one negative coeff
  32. if vevzero!? vev1 then goto finish; % nonneg. solution imposs.
  33. % homogenous polynomial: find combinations of
  34. % variables which are solutions
  35. x := h;
  36. vev1 := vdpevlmon x;
  37. vevl := vevsplit(vev1);
  38. problems := for each x in vevl collect list x;
  39. x := vdpred x;
  40. while not vdpzero!? x do
  41. << vev1 := vdpevlmon x;
  42. vevl := vevsplit(vev1);
  43. problems1 := nil;
  44. for each e in vevl do
  45. for each p in problems do
  46. <<r := if not member(e,p) then e . p else p;
  47. problems1 := union(list r, problems1)>>;
  48. problems := problems1;
  49. x := vdpred x >>;
  50. problems := % lift vevs to polynomials
  51. for each p in problems collect
  52. for each e in p collect
  53. vdpfmon(a2vbc 1,e);
  54. % rule out problems contained in others
  55. for each x in problems do
  56. for each y in problems do
  57. if not eq(x,y) and subset!?(x,y) then
  58. problems := delete (y,problems);
  59. % rule out some by cdr
  60. problems1 := nil;
  61. while problems do
  62. <<if vdpDisjoint!? (car problems,arg)
  63. then problems1 := car problems . problems1;
  64. problems := cdr problems >>;
  65. finish:
  66. groebmess24(h,problems1,arg);
  67. return
  68. if null problems1 then 'icancel
  69. else 'restriction . problems1 end;
  70. symbolic procedure groebpos(h,dummy);
  71. % test if h is a polynomial which can have the value zero with
  72. % only positive (nonnegative and nonzero) variable settings.
  73. begin scalar x,break,vev1;
  74. dummy := nil;
  75. if vdpzero!? h then return nil
  76. else
  77. if vevzero!? vdpevlmon h then return nil;
  78. % a simple monomial can never have pos. zeros
  79. if vdpredzero!? h then return groebposcancel(h);
  80. break := nil;
  81. x := h;
  82. % test coefficients
  83. while not vdpzero!? x and not break do
  84. <<vev1 := vdpevlmon x;
  85. if not vbcplus!? vdpLbc x then break := t;
  86. if not break then x := vdpred x>>;
  87. if not break then return groebPosCancel(h);
  88. if not groebposvevaluate h then groebPosCancel(h);
  89. return nil end;
  90. symbolic procedure groebposvevaluate h; <<h := nil; t>>;
  91. % test if a polynomial can become zero under user restrictions
  92. % here a dummy to be rplaced elsewhere
  93. symbolic procedure groebzero(h,dummy);
  94. begin scalar l;
  95. dummy := nil;
  96. l:=vdplastmon h;
  97. if l and vevzero!? cdr l then return groebPosCancel h;
  98. return nil end;
  99. symbolic procedure groebposcancel(h);
  100. <<groebmess24(h,nil,nil); 'cancel>>;
  101. endmodule;;end;