groext.red 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. module groext; % author: Herbert Melenk, ZIB Berlin.
  2. % version 3: removal of the return value 'superfluous' and
  3. % switching to 'groebnerf'.
  4. % version 4: extending ALL bases, which do not reduce the
  5. % polynomial to zero; 'groext11' has now a list for any
  6. % new polynmial with a '1', if the polynomial is not reduced
  7. % to zero by the basis; otherwise it has a '0'.
  8. % version 5: determine the subcases by Groebner base
  9. % computaions.
  10. create!-package('(groext),'(contrib groebner));
  11. load!-package 'groebner;put('groext,'psopfn,'groexteval);
  12. fluid'(groext11);groext11:='(list);share groext11;
  13. symbolic procedure groexteval u;
  14. begin scalar gg,ll,v;
  15. !*groebopt:=nil;
  16. if not(2=length u) then
  17. rerror(groext,1,"groext: illegal number of parameters.");
  18. gg:=reval car u;
  19. if not eqcar(gg,'list) then
  20. rerror(groext,2,"groext: first parameter must be a list of lists.");
  21. gg:=cdr gg;ll:=reval cadr u;
  22. if not eqcar(ll,'list) then
  23. rerror(groext,3,"groext: second parameter must be a list.");
  24. ll:=for each lll in cdr ll collect reval{'num,lll};
  25. v:=groext1(gg,ll);
  26. return if null u then 'empty else if v=t then car u else 'list.v end;
  27. symbolic procedure groext1(gg,ll);
  28. begin scalar a,aa,b,bb,c,ii,l;
  29. l:=length ll;
  30. gg:=for each ggg in gg collect ggg.for each gggg in ggg collect gggg;
  31. groext11:=nil;
  32. for each lll in ll do
  33. <<c:='list.for each ggg in gg collect
  34. <<a:=preduceeval{lll,car ggg};
  35. if a=0 then 0 else<<cdr ggg:=nconc(cdr ggg,{a});1>> >>;
  36. groext11:=c.groext11>>;
  37. groext11:='list.reversip groext11;
  38. for each ggg in gg do ii:=nconc(groext3 cdr ggg,ii);
  39. if null ii then return nil;
  40. % for each iii in ii do if null groext2(iii,ii) then jj:=iii.jj
  41. % else ii:=deletip(iii,ii);
  42. a:=ii;
  43. aa:if null a then go to cc;aa:=car a;a:=cdr a;b:=ii;
  44. bb:if null b then go to aa;bb:=car b;b:=cdr b;
  45. if groext2(aa,bb)then<<ii:=delete(bb,ii);a:=delete(bb,a)>>;go to bb;
  46. cc:return reversip ii end;
  47. symbolic procedure groext2(a,b);
  48. % Test, if the Groebner basis 'a' describes a subproblem of one of
  49. % the Groebner basis 'b'; return 't' then. Otherwise return 'nil'.
  50. if a eq b then nil else
  51. begin scalar !*groebfac;
  52. !*groebfac:=t;return if b=cadr groebner1(append(b,cdr a),nil,nil)then t
  53. else nil end;
  54. fluid'(!*groebfac);
  55. symbolic procedure groext3 a;
  56. % Simulate "Groebner a;".
  57. begin scalar b,!*groebfac;!*groebfac:=t;b:=groebner1(a,nil,nil);
  58. return if b='(list(list 1))then nil else cdr b end;
  59. endmodule;;end;