degsets.red 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. module degsets; % Degree set processing.
  2. % Authors: A. C. Norman and P. M. A. Moore, 1981.
  3. fluid '(!*trallfac
  4. !*trfac
  5. bad!-case
  6. best!-set!-pointer
  7. dpoly
  8. factor!-level
  9. factor!-trace!-list
  10. factored!-lc
  11. irreducible
  12. modular!-info
  13. one!-complete!-deg!-analysis!-done
  14. previous!-degree!-map
  15. split!-list
  16. valid!-image!-sets);
  17. symbolic procedure check!-degree!-sets(n,multivariate!-case);
  18. % MODULAR!-INFO (vector of size N) contains the modular factors now.
  19. begin scalar degree!-sets,w,x!-is!-factor,degs;
  20. w:=split!-list;
  21. for i:=1:n do <<
  22. if multivariate!-case then
  23. x!-is!-factor:=not numberp get!-image!-content
  24. getv(valid!-image!-sets,cdar w);
  25. degs:=for each v in getv(modular!-info,cdar w) collect ldeg v;
  26. degree!-sets:=
  27. (if x!-is!-factor then 1 . degs else degs)
  28. . degree!-sets;
  29. w:=cdr w >>;
  30. check!-degree!-sets!-1 degree!-sets;
  31. best!-set!-pointer:=cdar split!-list;
  32. if multivariate!-case and factored!-lc then <<
  33. while null(w:=get!-f!-numvec
  34. getv(valid!-image!-sets,best!-set!-pointer))
  35. and (split!-list:=cdr split!-list) do
  36. best!-set!-pointer:=cdar split!-list;
  37. if null w then bad!-case:=t >>;
  38. % make sure the set is ok for distributing the
  39. % leading coefft where necessary;
  40. end;
  41. symbolic procedure check!-degree!-sets!-1 l;
  42. % L is a list of degree sets. Try to discover if the entries
  43. % in it are consistent, or if they imply that some of the
  44. % modular splittings were 'false'.
  45. begin scalar i,degree!-map,degree!-map1,dpoly,
  46. plausible!-split!-found,target!-count;
  47. factor!-trace <<
  48. prin2t "Degree sets are:";
  49. for each s in l do <<
  50. prin2 " ";
  51. for each n in s do <<
  52. prin2 " "; prin2 n >>;
  53. terpri() >> >>;
  54. dpoly:=sum!-list car l;
  55. target!-count:=length car l;
  56. for each s in cdr l do
  57. target!-count:=min(target!-count,length s);
  58. % This used to be IMIN, but since it was the only use, it was
  59. % eliminated.
  60. if null previous!-degree!-map then <<
  61. degree!-map:=mkvect dpoly;
  62. % To begin with all degrees of factors may be possible;
  63. for i:=0:dpoly do putv(degree!-map,i,t) >>
  64. else <<
  65. factor!-trace "Refine an existing degree map";
  66. degree!-map:=previous!-degree!-map >>;
  67. degree!-map1:=mkvect dpoly;
  68. for each s in l do <<
  69. % For each degree set S I will collect in DEGREE-MAP1 a
  70. % bitmap showing what degree factors would be consistent
  71. % with that set. By ANDing together all these maps
  72. % (into DEGREE-MAP) I find what degrees for factors are
  73. % consistent with the whole of the information I have.
  74. for i:=0:dpoly do putv(degree!-map1,i,nil);
  75. putv(degree!-map1,0,t);
  76. putv(degree!-map1,dpoly,t);
  77. for each d in s do for i:=dpoly#-d#-1 step -1 until 0 do
  78. if getv(degree!-map1,i) then
  79. putv(degree!-map1,i#+d,t);
  80. for i:=0:dpoly do
  81. putv(degree!-map,i,getv(degree!-map,i) and
  82. getv(degree!-map1,i)) >>;
  83. factor!-trace <<
  84. prin2t "Possible degrees for factors are: ";
  85. for i:=1:dpoly#-1 do
  86. if getv(degree!-map,i) then << prin2 i; prin2 " " >>;
  87. terpri() >>;
  88. i:=dpoly#-1;
  89. while i#>0 do if getv(degree!-map,i) then i:=-1
  90. else i:=i#-1;
  91. if i=0 then <<
  92. factor!-trace
  93. prin2t "Degree analysis proves polynomial irreducible";
  94. return irreducible:=t >>;
  95. for each s in l do if length s=target!-count then begin
  96. % Sets with too many factors are not plausible anyway.
  97. i:=s;
  98. while i and getv(degree!-map,car i) do i:=cdr i;
  99. % If I drop through with I null it was because the set was
  100. % consistent, otherwise it represented a false split;
  101. if null i then plausible!-split!-found:=t end;
  102. previous!-degree!-map:=degree!-map;
  103. if plausible!-split!-found or one!-complete!-deg!-analysis!-done
  104. then return nil;
  105. % PRINTC "Going to try getting some more images";
  106. return bad!-case:=t
  107. end;
  108. symbolic procedure sum!-list l;
  109. if null cdr l then car l else car l #+ sum!-list cdr l;
  110. endmodule;
  111. end;