odim.red 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. module odim;
  2. COMMENT
  3. ##########################################
  4. ## ##
  5. ## Applications to zerodimensional ##
  6. ## ideals and modules. ##
  7. ## ##
  8. ##########################################
  9. getkbase returns a k-vector space basis of S^c/M,
  10. odim_borderbasis computes a borderbasis of M,
  11. odim_up finds univariate polynomials in zerodimensional ideals.
  12. END COMMENT;
  13. % -------------- Test for zero dimension -----------------
  14. % For a true answer m must be a gbasis.
  15. put('dimzerop,'psopfn,'odim!=zerop);
  16. symbolic procedure odim!=zerop m;
  17. begin scalar c;
  18. intf_test m; intf_get(m:=car m);
  19. if not (c:=get(m,'gbasis)) then
  20. put(m,'gbasis,c:=gbasis!* get(m,'basis));
  21. if dimzerop!* c then return 'yes else return 'no;
  22. end;
  23. symbolic procedure dimzerop!* m; null odim_parameter m;
  24. symbolic procedure odim_parameter m;
  25. % Return a parameter of the dpmat m or nil, if it is zerodimensional
  26. % or (1).
  27. odim!=parameter moid_from_dpmat m;
  28. symbolic procedure odim!=parameter m;
  29. if null m then nil
  30. else odim!=parameter1 cdar m or odim!=parameter cdr m;
  31. symbolic procedure odim!=parameter1 m;
  32. if null m then
  33. ((if u then car u else u)
  34. where u:= reverse ring_names cali!=basering)
  35. else if mo_zero!? car m then nil
  36. else begin scalar b,u;
  37. u:=for each x in m join if length(b:=mo_support x)=1 then b;
  38. b:=reverse ring_names cali!=basering;
  39. while b and member(car b,u) do b:=cdr b;
  40. return if b then car b else nil;
  41. end;
  42. % --- Get a k-base of F/M as a list of monomials ----
  43. % m must be a gbasis for the correct result.
  44. put('getkbase,'psopfn,'odim!=evkbase);
  45. symbolic procedure odim!=evkbase m;
  46. begin scalar c;
  47. intf_test m; intf_get(m:=car m);
  48. if not (c:=get(m,'gbasis)) then
  49. put(m,'gbasis,c:=gbasis!* get(m,'basis));
  50. return moid_2a getkbase!* c;
  51. end;
  52. symbolic procedure getkbase!* m;
  53. if not dimzerop!* m then rederr"dpmat not zerodimensional"
  54. else for each u in moid_from_dpmat m join
  55. odim!=kbase(mo_from_ei car u,ring_names cali!=basering,cdr u);
  56. symbolic procedure odim!=kbase(mo,n,m);
  57. if moid_member(mo,m) then nil
  58. else mo . for each x on n join
  59. odim!=kbase(mo_inc(mo,car x,1),append(x,nil),m);
  60. % --- Produce an univariate polynomial inside the ideal m ---
  61. symbolic procedure odim_up(a,m);
  62. % Returns a univariate polynomial (of smallest possible degree if m
  63. % is a gbasis) in the variable a inside the zerodimensional ideal m.
  64. % Uses Buchberger's approach.
  65. if dpmat_cols m>0 or not dimzerop!* m then
  66. rederr"univariate polynomials only for zerodimensional ideals"
  67. else if not member(a,ring_names cali!=basering) then
  68. typerr(a,"variable name")
  69. else if dpmat_unitideal!? m then dp_fi 1
  70. else begin scalar b,v,p,l,q,r;
  71. % l is a list of ( p(a) . NF p(a) ), sorted by lt NF p(a)
  72. p:=(dp_fi 1 . dp_fi 1); b:=dpmat_list m; v:=mo_from_a a;
  73. while cdr p do
  74. << l:=merge(list p,l,function odim!=greater);
  75. q:=dp_times_mo(v,car p);
  76. r:=red_redpol(b,bas_make(0,dp_times_mo(v,cdr p)));
  77. p:=odim!=reduce(dp_prod(cdr r,q) . bas_dpoly car r,l);
  78. >>;
  79. return
  80. if !*bcsimp then car dp_simp car p
  81. else car p;
  82. end;
  83. symbolic procedure odim!=greater(a,b);
  84. mo_compare(dp_lmon cdr a,dp_lmon cdr b)=1;
  85. symbolic procedure odim!=reduce(a,l);
  86. if null cdr a or null l or odim!=greater(a, car l) then a
  87. else if mo_equal!?(dp_lmon cdr a,dp_lmon cdar l) then
  88. begin scalar z,z1,z2,b;
  89. b:=car l; z1:=bc_neg dp_lc cdr a; z2:=dp_lc cdr b;
  90. if !*bcsimp then
  91. << if (z:=bc_inv z1) then <<z1:=bc_fi 1; z2:=bc_prod(z2,z)>>
  92. else
  93. << z:=bc_gcd(z1,z2);
  94. z1:=car bc_divmod(z1,z);
  95. z2:=car bc_divmod(z2,z);
  96. >>;
  97. >>;
  98. a:=dp_sum(dp_times_bc(z2,car a),dp_times_bc(z1,car b)) .
  99. dp_sum(dp_times_bc(z2,cdr a),dp_times_bc(z1,cdr b));
  100. return odim!=reduce(a,cdr l)
  101. end
  102. else odim!=reduce(a,cdr l);
  103. % ------------------------- Borderbasis -----------------------
  104. symbolic procedure odim_borderbasis m;
  105. % Returns a border basis of the zerodimensional dpmat m as list of
  106. % base elements.
  107. if not !*noetherian then
  108. rederr"BORDERBASIS only for non noetherian term orders"
  109. else if not dimzerop!* m then
  110. rederr"BORDERBASIS only for zerodimensional ideals or modules"
  111. else begin scalar b,v,u,mo,bas;
  112. bas:=bas_zerodelete dpmat_list m;
  113. mo:=for each x in bas collect dp_lmon bas_dpoly x;
  114. v:=for each x in ring_names cali!=basering collect mo_from_a x;
  115. u:=for each x in bas collect
  116. {dp_lmon bas_dpoly x,red_tailred(bas,x)};
  117. while u do
  118. << b:=append(b,u);
  119. u:=listminimize(
  120. for each x in u join
  121. for each y in v join
  122. (begin scalar w; w:=mo_sum(first x,y);
  123. if not listtest(b,w,function(lambda(x,y);car x=y))
  124. and not odim!=interior(w,mo) then
  125. return {{w,y,bas_dpoly second x}}
  126. end),
  127. function(lambda(x,y);car x=car y));
  128. u:=for each x in u collect
  129. {first x,
  130. red_tailred(bas,bas_make(0,dp_times_mo(second x,third x)))};
  131. >>;
  132. return bas_renumber for each x in b collect second x;
  133. end;
  134. symbolic procedure odim!=interior(m,mo);
  135. % true <=> monomial m is in the interior of the moideal mo.
  136. begin scalar b; b:=t;
  137. for each x in mo_support m do
  138. b:=b and moid_member(mo_diff(m,mo_from_a x),mo);
  139. return b;
  140. end;
  141. endmodule; % odim
  142. end;