edsnorml.red 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. module edsnormal;
  2. % Converting exterior systems to internal form
  3. % Author: David Hartley
  4. Comment. The next section contains routines for putting an EDS into
  5. "normal" form. An EDS S is in "normal" form if
  6. *** 1) S contains no 0-forms, *** removed 27/4/95
  7. 2) the 1-forms {theta(a)} in S satisfy
  8. lc theta(a) = 1
  9. lpow theta(a) in xpows theta(b) iff a = b.
  10. 3) the 1-forms {omega(i)} in eds_ind S are reduced mod {theta(a)}
  11. and satisfy
  12. trc omega(i) = 1
  13. trpow omega(i) in xpows omega(j) iff i = j
  14. where trc/trpow mean trailing coefficient/power.
  15. 4) S\{theta(a)} is in normal form mod {theta(a)}.
  16. If S satisfies 1, it is "generated in positive degree". If S satisfies
  17. 2, and 3, it is in "solved" form. If S satisfies 4, it is "reduced".
  18. endcomment;
  19. fluid '(cfrmrsx!* !*edssloppy pullback_maps xvars!* kord!*);
  20. symbolic procedure normaleds s;
  21. % s:eds -> normaleds:eds
  22. % Bring s into normal form as far as possible.
  23. if normaledsp s then s
  24. % else if emptyedsp(s := solvededs s) then s
  25. % else positiveeds sorteds reducededs s;
  26. else sorteds reducededs solvededs s;
  27. symbolic procedure normaledsp s;
  28. % s:eds -> normaledsp:bool
  29. solvededsp s and
  30. reducededsp s;
  31. % null scalarpart eds_sys s;
  32. put('lift,'edsfn,'positiveeds);
  33. put('lift,'rtypefn,'getrtypecar);
  34. symbolic procedure positiveeds s;
  35. % s:eds -> positiveeds:xeds
  36. % Bring s into positive form as far as possible.
  37. begin scalar v,c,s1;
  38. v := foreach f in scalarpart eds_sys s collect lc f;
  39. if null v then return s;
  40. edsverbose("Solving 0-forms",nil,nil);
  41. eds_sys s := setdiff(eds_sys s,v);
  42. c := reverse setdiff(edscrd s,edsindcrd s);
  43. c := edsgradecoords(c,geteds(s,'jet0));
  44. v := edssolvegraded(v,c,cfrm_rsx eds_cfrm s);
  45. s := purgexeds makelist
  46. if null v then
  47. << edsverbose("System inconsistent",nil,nil); {}>>
  48. else foreach strata in v collect
  49. if null car strata then
  50. << edsverbose("Couldn't solve 0-forms",cdr strata,'sq);
  51. strata := foreach q in cdr strata collect 1 .* q .+ nil;
  52. augmentsys(s,strata) >>
  53. else
  54. << edsverbose("New equations:",cadr strata,'map);
  55. %%% pullback_maps:= append(pullback_maps,{!*rmap2a cdr strata});
  56. s1 := pullback0(s,cdr strata); % might add 0-forms
  57. if null scalarpart eds_sys s1 then s1
  58. else edscall positiveeds s1 >>; % so go round again
  59. return s;
  60. end;
  61. flag('(reduced solved),'hidden); % non-printing and purgeable
  62. symbolic procedure reducededs s;
  63. % s:eds -> reducededs:eds
  64. % Bring s into reduced form as far as possible.
  65. % Changes background coframing.
  66. if knowntrueeds(s,'reduced) then s else
  67. begin scalar m,p,q;
  68. m := setcfrm eds_cfrm!* s;
  69. p := solvedpart pfaffpart eds_sys s;
  70. q := foreach f in setdiff(eds_sys s,p) join
  71. if f := xreduce(f,p) then
  72. {if cfrmnowherezero numr lc f then xnormalise f else f};
  73. eds_sys s := append(p,q);
  74. flagtrueeds(s,'reduced);
  75. return s;
  76. end;
  77. symbolic procedure reducededsp s;
  78. % s:eds -> reducededsp:bool
  79. knowntrueeds(s,'reduced);
  80. symbolic procedure solvededs s;
  81. % s:eds -> solvededs:eds
  82. % Bring s into solved form as far as possible.
  83. % Local variables:
  84. % m - coframing for s
  85. % n - external background coframing
  86. % p - solved part of 1-forms in s
  87. % q - unsolved part of 1-forms in s
  88. % z - 0-forms picked up from 1-forms in s
  89. % i - independence 1-forms
  90. % ik - independent kernels (cf indkrns)
  91. % dk - dependent kernels (cf depkrns)
  92. % pk - principal kernels (cf prlkrns)
  93. % kl - cobasis (cf edscob)
  94. if knowneds(s,'solved) then s else
  95. begin scalar m,n,p,q,z,i,ik,dk,pk,kl;
  96. m := copycfrm eds_cfrm!* s;
  97. % Set up coframing and initial ordering
  98. i := xautoreduce eds_ind s; % check if indkrns are obvious
  99. i := if !*edssloppy or singleterms i then reverse lpows i else {};
  100. kl := append(setdiff(cfrm_cob m,i),i);
  101. cfrm_cob m := kl;
  102. n := setcfrm m;
  103. % Put 1-forms into solved form as far as possible
  104. edsdebug("Solving Pfaffian subsystem",nil,nil);
  105. q := solvepfsys1(pfaffpart eds_sys s,
  106. if !*edssloppy then setdiff(cfrm_cob m,i));
  107. p := car q;
  108. dk := lpows p;
  109. % Put independence 1-forms into solved form mod p
  110. edsdebug("Solving independence forms",nil,nil);
  111. i := solvepfsys1(foreach f in eds_ind s join
  112. if f := xreduce(xreorder f,p) then {f},
  113. if !*edssloppy then i);
  114. if length eds_ind s > length car i + length cadr i then
  115. return <<edsverbose("System inconsistent",nil,nil);
  116. setcfrm n;
  117. emptyeds()>>;
  118. ik := lpows car i;
  119. % Check for f(i)*omega(i) 1-forms from q
  120. q := foreach f in cadr q join
  121. if xreduce(f := xreorder f,car i) then {f}
  122. else
  123. <<z := union(foreach w in ik join
  124. if w := xcoeff(f,wedgefax w) then {w},
  125. z);
  126. nil>>;
  127. if z then edsverbose("New 0-form conditions detected",z,'sys);
  128. % Set final ordering
  129. pk := setdiff(kl,append(dk,ik));
  130. kl := append(dk,append(pk,ik)); % dep > prl > ind
  131. updkordl kl;
  132. % Construct final eds
  133. m := copycfrm eds_cfrm s;
  134. s := copyeds s;
  135. eds_sys s :=
  136. xreordersys append(z,append(p,append(q,nonpfaffpart eds_sys s)));
  137. eds_ind s := xreordersys append(car i,cadr i);
  138. cfrm_cob m := kl;
  139. eds_cfrm s := m;
  140. if !*edssloppy then eds_cfrm s := updatersx eds_cfrm s;
  141. % Fix flags
  142. if q or cadr i then flagfalseeds(s,'solved)
  143. else flagtrueeds(s,'solved);
  144. rempropeds(s,'reduced);
  145. if z then remtrueeds(s,'closed);
  146. remkrns s;
  147. setcfrm n;
  148. return s;
  149. end;
  150. symbolic procedure xreordersys p;
  151. % p:sys -> xreordersys:sys
  152. foreach f in p collect xreorder f;
  153. symbolic procedure solvededsp s;
  154. % s:eds -> solvededsp:bool
  155. knowntrueeds(s,'solved);
  156. symbolic procedure reordereds s;
  157. % s:eds -> reordereds:eds
  158. % Reorder s according to current kernel order as far as possible.
  159. begin scalar r,k;
  160. r := copyeds s;
  161. k := rightunion(kord!*,edscob r);
  162. eds_sys r := sortsys(xreordersys eds_sys r,k);
  163. eds_ind r := sortsys(xreordersys eds_ind r,k);
  164. eds_cfrm r := reordercfrm eds_cfrm r;
  165. return if r = s then s else normaleds r;
  166. end;
  167. symbolic procedure sorteds s;
  168. % s:eds -> sorteds:eds
  169. begin scalar k;
  170. s := copyeds s;
  171. k := edscob s;
  172. eds_sys s := sortsys(eds_sys s,k);
  173. eds_ind s := sortsys(eds_ind s,k);
  174. return s;
  175. end;
  176. symbolic procedure sortsys(s,c);
  177. % s:sys, c:cob -> sortsys:sys
  178. % sort forms by degree, should add some more stuff.
  179. reversip sort(s,function pfordp)
  180. where kord!* = reverse c;
  181. endmodule;
  182. end;