prolong.red 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. module prolong;
  2. % Prolonged systems, tableaux
  3. % Author: David Hartley
  4. fluid '(!*edsverbose !*edsdebug !*arbvars !*varopt !*groebopt
  5. !*solveinconsistent depl!* !*edssloppy pullback_maps);
  6. % Grassmann bundle variety
  7. put('grassmann_variety,'rtypefn,'getrtypecar);
  8. put('grassmann_variety,'edsfn,'grassmannvariety);
  9. flag('(grassmannvariety grassmannvarietysolution
  10. grassmannvarietytorsion),'hidden);
  11. symbolic procedure grassmannvariety s;
  12. % s:eds -> grassmannvariety:eds
  13. % Reduced Grassmann contact system together with Grassmann variety
  14. % conditions as one system with 0-forms
  15. begin scalar p,g,s0,v;
  16. if g := geteds(s,'grassmannvariety) then return g;
  17. s0 := closure s;
  18. g := gbsys s0;
  19. p := solvedpart pfaffpart eds_sys s0;
  20. % reduction in next lines ok since lpows g = prlkrns s0
  21. foreach f in setdiff(eds_sys s0,p) do
  22. v := union(foreach q in xcoeffs xreduce(f,eds_sys g) collect
  23. 1 .* q .+ nil,v);
  24. g := augmentsys(g,append(v,p));
  25. puteds(s,'grassmannvariety,g);
  26. return g;
  27. end;
  28. % Prolongation
  29. put('prolong,'rtypefn,'quoteeds);
  30. put('prolong,'edsfn,'prolongeds);
  31. symbolic procedure prolongeds s;
  32. % s:eds -> prolongeds:xeds
  33. begin
  34. pullback_maps := makelist {};
  35. return
  36. if not edsp s then typerr(s,'eds)
  37. else mkxeds makelist
  38. foreach x in prolong s join
  39. if cdr x then {cdr x};
  40. end;
  41. symbolic procedure prolong s;
  42. % s:eds -> prolong:list of tag.eds
  43. % where tag is one of
  44. % prolonged s was prolonged
  45. % reduced s was reduced
  46. % failed couldn't solve Grassmann variety conditions (eds
  47. % is {Grassmann system with variety conditions})
  48. % inconsistent prolongation is inconsistent
  49. % eds_ind s is preserved by prolong. Note the
  50. % heuristic to eliminate independent variables is incomplete.
  51. begin scalar g,v,s1;
  52. g := copyeds grassmannvariety s;
  53. updkordl edscob g;
  54. eds_sys g := setdiff(eds_sys g,scalarpart eds_sys g);
  55. v := decomposegrassmannvariety s;
  56. return if null v then
  57. << edsverbose("Prolongation inconsistent",nil,nil);
  58. eds_sys g := {!*k2pf 1};
  59. {'inconsistent . g} >>
  60. else foreach strata in v join
  61. if car strata = 'failed then
  62. << edsverbose("Prolongation failed - solution variety:",
  63. cdr strata,'sq);
  64. {'failed .
  65. augmentsys(g,foreach q in cdr strata collect 1 .* q .+ nil)}
  66. >>
  67. else if car strata = 'base then
  68. << edsverbose("Reduction using new equations:",cdr strata,'rmap);
  69. pullback_maps := append(pullback_maps,{!*rmap2a cdr strata});
  70. s1 := edscall pullback0(s,cdr strata);
  71. if scalarpart eds_sys s1 then
  72. s1 := edscall positiveeds s1;
  73. if emptyedsp s1 then {'inconsistent . s1}
  74. else if edsp s1 then {'reduced . s1}
  75. else foreach s2 in getrlist s1 collect 'reduced . s2 >>
  76. else if car strata = 'fibre then
  77. << if cadr strata then
  78. edsverbose("Prolongation using new equations:",
  79. cdr strata,'rmap)
  80. else
  81. edsverbose("Prolongation (no new equations)",nil,nil);
  82. pullback_maps := append(pullback_maps,{!*rmap2a cdr strata});
  83. s1 := edscall pullback0(g,cdr strata);
  84. {'prolonged . s1} >>;
  85. end;
  86. symbolic procedure decomposegrassmannvariety s;
  87. % s:eds -> decomposegrassmannvariety:list of tag.value
  88. % where tag.value is one of
  89. % 'fibre.rmap s can be prolonged
  90. % 'base.rmap s must be reduced
  91. % 'failed . list of sq couldn't solve Grassmann variety
  92. % conditions
  93. % 'inconsistent.nil Grassmann variety empty
  94. begin scalar g,v,c,b;
  95. g := grassmannvariety s;
  96. c := reverse setdiff(edscrd g,edsindcrd g);
  97. c := edsgradecoords(c,geteds(g,'jet0));
  98. % Allow for case where g has no fibre coordinates (s has finite type)
  99. if null setdiff(edscrd g,edscrd s) then c := {} . c;
  100. if semilinearp s then
  101. if v := grassmannvarietytorsion s then
  102. if null(v := edssolvegraded(v,cdr c,cfrm_rsx eds_cfrm s))
  103. then return {'inconsistent . nil}
  104. else return foreach m in v collect
  105. if car m then 'base . cdr m
  106. else 'failed . cdr m
  107. else if v := partsolvegrassmannvariety s then return
  108. {'fibre . !*map2rmap
  109. foreach x in car v join if not(car x memq cadr v) then
  110. {car x . mk!*sq subsq(simp!* cdr x,caddr v)}}
  111. else errdhh "Bad solution to semilinear system"
  112. else % not semilinearp s
  113. << v := foreach f in scalarpart eds_sys g collect lc f;
  114. if null(v := edssolvegraded(v,c,cfrm_rsx eds_cfrm s))
  115. then return {'inconsistent . nil}
  116. else return foreach m in v collect
  117. if null car m then 'failed . cdr m
  118. else if (b := foreach s in cadr m join
  119. if not memq(car s,car c) then {s}) then
  120. 'base . {b,for each p in caddr m
  121. join if freeofl(p,car c) then {p}}
  122. else 'fibre . cdr m; >>;
  123. end;
  124. % Special routines for semilinear systems
  125. symbolic procedure partsolvegrassmannvariety s;
  126. % s:eds -> partsolvegrassmannvariety:{map,list of kernel,map}
  127. % Partly solves the variety equations for a linear system s.
  128. % The "solution" is returned as from edspartsolve.
  129. begin scalar v,c;
  130. if v := geteds(s,'grassmannvarietysolution) then return v;
  131. v := grassmannvariety s;
  132. c := reverse setdiff(edscrd v,edscrd s);
  133. v := foreach f in scalarpart eds_sys v collect lc f;
  134. v := edspartsolve(v,c);
  135. puteds(s,'grassmannvarietysolution,v);
  136. return v;
  137. end;
  138. put('dim_grassmann_variety,'simpfn,'dimgrassmannvarietyeval);
  139. symbolic procedure dimgrassmannvarietyeval u;
  140. % u:{eds}|{eds,sys} -> dimgrassmannvarietyeval:sq
  141. if length u < 1 or length u > 2 then
  142. rerror(eds,000,
  143. "Wrong number of arguments to dim_grassmann_variety")
  144. else if edsp car(u := revlis u) then
  145. edscall dimgrassmannvariety(car u,if cdr u then !*a2sys cadr u)
  146. ./ 1
  147. else typerr(car u,"EDS");
  148. symbolic procedure dimgrassmannvariety(s,x);
  149. % s:eds, x:sys -> dimgrassmannvariety:int
  150. begin scalar v,c;
  151. if not quasilinearp s then
  152. if null x then
  153. rerror(eds,000,"Integral element required for nonlinear EDS")
  154. else
  155. s := linearise(s,x);
  156. v := grassmannvariety s;
  157. c := length setdiff(edscrd v,edscrd s);
  158. % Treat quasilinear and semilinear systems the same
  159. % Will storing the solution etc cause trouble for q-l. s?
  160. v := partsolvegrassmannvariety s;
  161. c := c - foreach x in car v sum
  162. if car x memq cadr v then 0 else 1;
  163. return c;
  164. end;
  165. put('torsion,'rtypefn,'quotelist);
  166. put('torsion,'listfn,'torsioneval);
  167. symbolic procedure torsioneval(u,v);
  168. % u:{eds}, v:bool -> torsioneval:rlist
  169. if not edscall semilinearp(u := reval car u) then
  170. rerror(eds,000,"TORSION available for semi-linear systems only")
  171. else
  172. makelist for each q in edscall grassmannvarietytorsion u
  173. collect !*q2a1(q,v);
  174. symbolic procedure grassmannvarietytorsion s;
  175. % s:eds -> grassmannvarietytorsion:list of sf
  176. begin scalar v;
  177. if v := geteds(s,'grassmannvarietytorsion) then return v;
  178. v := partsolvegrassmannvariety s;
  179. v := foreach x in car v join
  180. if car x memq cadr v and numr
  181. << x := addsq(negsq !*k2q car x,simp!* cdr x);
  182. x := subsq(x,caddr v) >>
  183. then {x};
  184. puteds(s,'grassmannvarietytorsion,v);
  185. return v;
  186. end;
  187. endmodule;
  188. end;