ncenv.red 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. module ncenv; % Non-communtative polynomial ring environment.
  2. % This module organizes an environment for computing with
  3. % non-commutative polynomials in algebraic mode, and an embedding
  4. % for non-commutative Groebner bases.
  5. % Author: H. Melenk, ZIB Berlin, J. Apel, University of Leipzig
  6. % Copyright: Konrad-Zuse-Zentrum Berlin, 1994
  7. share ncpi!-brackets!*,ncpi!-comm!-rules!*,ncpi!-name!-rules!*;
  8. algebraic operator nc!*;
  9. algebraic noncom nc!*;
  10. put('nc!*,'prifn,'pri!-nc!*);
  11. put('nc!*,'dipprifn,'dippri!-nc!*);
  12. symbolic procedure pri!-nc!* u;
  13. prin2!*(w and cdr w or u) where w=assoc(u,ncpi!-names!*);
  14. symbolic procedure dippri!-nc!* u;
  15. dipprin2(w and cdr w or u) where w=assoc(u,ncpi!-names!*);
  16. symbolic procedure ncpi!-setup u;
  17. begin scalar vars,al,b,b0,f,m,rs,rn,na,rh,lh,s,x,y,w,!*evallhseqp;
  18. if (w:=member('left,u)) or (w:=member('right,u)) then
  19. <<u:=delete(car w,u);!*ncg!-right:=car w='right>>;
  20. if length u > 2 then rederr "illegal number of arguments";
  21. if ncpi!-name!-rules!* then
  22. algebraic clearrules ncpi!-comm!-rules!*,ncpi!-name!-rules!*;
  23. u:=sublis(ncpi!-names!*,u);
  24. for each x in cdr listeval(car u,nil) collect
  25. <<x:=reval x;y:={'nc!*,mkid('!_,x)}; na:=(y.x).na;
  26. rn:={'replaceby,x,y}.rn; al:=(x.y).al;vars:=append(vars,{y})>>;
  27. ncpi!-names!*:=na;
  28. ncpi!-name!-rules!*:='list.rn;
  29. m:=for i:=1:length vars -1 join
  30. for j:=i+1:length vars collect nth(vars,i).nth(vars,j);
  31. if cdr u then ncpi!-brackets!*:=listeval(cadr u,nil);
  32. if null ncpi!-brackets!* then rederr "commutator relations missing";
  33. for each b in cdr ncpi!-brackets!* do
  34. <<b0:=sublis(al,b);
  35. w:= eqcar(b0,'equal) and (lh:=cadr b0) and (rh:=caddr b0)
  36. and eqcar(lh,'difference) and (f:=cadr lh) and (s:=caddr lh)
  37. and eqcar(f,'times) and eqcar(s,'times)
  38. and (x:=cadr f) and (y:=caddr f) and member(x,vars) and member(y,vars)
  39. and x=caddr s and y=cadr s;
  40. if not w then typerr(b,"commutator relation");
  41. % Invert commutator if necessary.
  42. if member(x.y,m) then <<w:=x;x:=y;y:=w; rh:={'minus,rh}>>;
  43. m:=delete(y.x,m);
  44. rs:={'replaceby,{'times,x,y},{'plus,{'times,y,x},rh}}.rs>>;
  45. % Initialize non-commutative distributive Polynomials.
  46. ncdsetup!*{'list.vars,'list.rs};
  47. apply('korder,{vars});
  48. apply('order,{vars});
  49. % Rules for commutating objects.
  50. for each c in m do
  51. rs:={'replaceby,{'times,cdr c,car c},{'times,car c,cdr c}}.rs;
  52. ncpi!-comm!-rules!*:='list.rs;
  53. algebraic let ncpi!-comm!-rules!*,ncpi!-name!-rules!* end;
  54. put('nc_setup,'psopfn,'ncpi!-setup);
  55. symbolic procedure nc_cleanup();
  56. <<algebraic clearrules ncpi!-comm!-rules!*,ncpi!-name!-rules!*;
  57. algebraic korder nil;algebraic order nil>>;
  58. put('nc_cleanup,'stat,'endstat);
  59. endmodule;;end;