evalmaps.red 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. module evalmaps; % Interaction with alg mode: variant without nonlocs;
  2. exports strand!-alg!-top $
  3. imports color!-strand,contract!-strand $
  4. %------------------ AUXILIARY ROUTINES -----------------------------$
  5. symbolic procedure permpl(u,v)$
  6. if null u then t
  7. else if car u = car v then permpl(cdr u,cdr v)
  8. else not permpl(cdr u,l!-subst1(car v,car u,cdr v))$
  9. symbolic procedure repeatsp u$
  10. if null u then nil
  11. else (member(car u,cdr u) or repeatsp cdr u )$
  12. symbolic procedure l!-subst1(new,old,l)$
  13. if null l then nil
  14. else if old = car l then new . cdr l
  15. else (car l) . l!-subst1(new,old,cdr l)$
  16. %-------------------FORMING ANTISYMMETRIHERS -----------------------$
  17. symbolic procedure propagator(u,v)$
  18. if null u then 1
  19. else if (repeatsp u) or (repeatsp v) then 0
  20. else 'plus . propag(u,permutations v,v)$
  21. symbolic procedure propag(u,l,v)$
  22. if null l then nil
  23. else (if permpl(v,car l) then 'times . prpg(u,car l)
  24. else list('minus,'times . prpg(u,car l) ) ) . propag(u,cdr l,v)$
  25. symbolic procedure prpg(u,v)$
  26. if null u then nil
  27. else list('cons,car u,car v) . prpg(cdr u,cdr v)$
  28. symbolic procedure line(x,y)$
  29. propagator(cdr x,cdr y)$
  30. %------------------ INTERFACE WITH CVIT3 ---------------------------$
  31. symbolic procedure strand!-alg!-top(strand,map_,edlst)$
  32. begin
  33. scalar rlst$
  34. strand:=deletez1(strand,edlst)$
  35. rlst:=color!-strand(edlst,map_,1)$
  36. strand:=contract!-strand(strand,rlst) $
  37. %RINT STRAND$ TERPRI()$
  38. %RINT RLST$ TERPRI()$
  39. %RINT EDLST$ TERPRI()$
  40. return dstr!-to!-alg(strand,rlst,nil)
  41. %ATHPRINT REVAL(W)$ RETURN W
  42. end$
  43. symbolic procedure mktails(side,rlst,dump)$
  44. begin
  45. scalar pntr,newdump,w,z$
  46. if null side then return nil . dump$
  47. pntr:=side$
  48. newdump:=dump$
  49. while pntr do << w:=mktails1(car pntr,rlst,newdump)$
  50. newdump:=cdr w$
  51. z:=sappend(car w,z)$
  52. pntr:=cdr pntr >>$
  53. return z . newdump
  54. end$
  55. symbolic procedure mktails1(rname,rlst,dump)$
  56. begin
  57. scalar color,prename,z$
  58. color:=getroad(rname,rlst)$
  59. if 0 = color then return nil . dump$
  60. if 0 = cdr rname then
  61. return (list replace_by_vector car rname) . dump$
  62. % IF FREEIND CAR RNAME THEN RETURN (LIST CAR RNAME) . DUMP$
  63. z:=assoc(rname,dump)$
  64. if z then return
  65. if null cddr z then cdr z . dump
  66. else (sreverse cdr z) . dump$
  67. % PRENAME:=APPEND(EXPLODE CAR RNAME,EXPLODE CDR RNAME)$
  68. prename:=rname$
  69. z:= mkinds(prename,color)$
  70. return z . ((rname . z) . dump)
  71. end$
  72. symbolic procedure mkinds(prename,color)$
  73. if color = 0 then nil
  74. else
  75. begin
  76. scalar indx$
  77. % INDX:=INTERN COMPRESS APPEND(PRENAME,EXPLODE COLOR)$
  78. indx:= prename . color $
  79. return indx . mkinds(prename,sub1 color)
  80. end$
  81. symbolic procedure getroad(rname,rlst)$
  82. if null rlst then 1 % ******EXT LEG IS ALWAYS SUPPOSET TO BE SIMPLE $
  83. else if cdr rname = cdar rlst then
  84. cdr qassoc(car rname,caar rlst)
  85. else getroad(rname,cdr rlst) $
  86. symbolic procedure qassoc(atm,alst)$
  87. if null alst then nil
  88. else if eq(atm,caar alst) then car alst
  89. else qassoc(atm,cdr alst)$
  90. %------------- INTERACTION WITH RODIONOV ---------------------------$
  91. symbolic procedure from!-rodionov x$
  92. begin scalar strand,edges,edgelsts,map_,w$
  93. edges:=car x$
  94. map_:=cadr x$
  95. edgelsts:=cddr x$
  96. strand := map_!-to!-strand(edges,map_)$
  97. w:= for each edlst in edgelsts collect
  98. strand!-alg!-top(strand,map_,edlst)$
  99. return reval('plus . w )
  100. end$
  101. symbolic procedure top1 x$
  102. mathprint from!-rodionov to_taranov x$
  103. %----------------------- COMBINATORIAL COEFFITIENTS -----------------$
  104. symbolic procedure f!^(n,m)$
  105. if n<m then cviterr "Incorrect args of f!^"
  106. else if n = m then 1
  107. else n*f!^(sub1 n,m)$
  108. %% This exists in basic REDUCE these days -- JPff
  109. %%symbolic procedure factorial n$
  110. %%f!^(n,0)$
  111. symbolic procedure mk!-coeff1(alist,rlst)$
  112. if null alist then 1
  113. else
  114. eval ('times .
  115. for each x in alist collect factorial getroad(car x,rlst) )$
  116. %--------------- CONTRACTION OF DELTA'S -----------------------------$
  117. symbolic procedure prop!-simp(l1,l2)$
  118. prop!-simp1(l1,l2,nil,0,1)$
  119. symbolic procedure prop!-simp1(l1,l2,s,lngth,sgn)$
  120. if null l2 then list(lngth,sgn) . (l1 . sreverse s)
  121. else
  122. (lambda z$ if null z then
  123. prop!-simp1(l1,cdr l2,car l2 . s,lngth,sgn)
  124. else prop!-simp1(cdr z,cdr l2,s,add1 lngth,
  125. (car z)*sgn*(-1)**(length s)) )
  126. prop!-simp2(l1,car l2)$
  127. symbolic procedure prop!-simp2(l,ind)$
  128. begin
  129. scalar sign$
  130. if sign:=index!-in(ind,l) then
  131. return ((-1)**(length(l)-length(sign))) . delete(ind,l)
  132. else return nil
  133. end$
  134. symbolic procedure mk!-contract!-coeff u$
  135. if caar u = 0 then 1
  136. else
  137. begin
  138. scalar numr,denr,pk,k$
  139. pk:=caar u$
  140. k:=length cadr u$
  141. numr:=constimes ((cadar u) .mk!-numr(ndim!*,k,k+pk))$
  142. % denr:=f!^(pk+k,k)*(cadar u)$
  143. return numr
  144. end$
  145. symbolic procedure mk!-numr(n,k,p)$
  146. if k=p then nil
  147. else (if k=0 then n else list('difference,n,k)) . mk!-numr(n,add1 k,p)$
  148. symbolic procedure mod!-index(term,dump)$
  149. %-------------------------------------------------------------------
  150. % MODYFIES INDECES OF "DUMP" VIA DELTAS IN "TERM"
  151. % DELETES UTILIZED DELTAS FROM "TERM"
  152. % RETURNS "TERM" . "DUMP"
  153. %------------------------------------------------------------------$
  154. begin
  155. scalar coeff,sign$
  156. coeff:=list 1$
  157. term:= if sign:= eq(car term,'minus) then cdadr term
  158. else cdr term$
  159. while term do << if free car term then
  160. coeff:=(car term) . coeff
  161. else dump:=mod!-dump(cdar term,dump)$
  162. term:=cdr term >>$
  163. return
  164. ( if sign then
  165. if null cdr coeff then (-1)
  166. else 'minus . list(constimes coeff)
  167. else if null cdr coeff then 1
  168. else constimes coeff ) . dump
  169. end$
  170. symbolic procedure dpropagator(l1,l2,dump)$
  171. (lambda z$
  172. if z=0 then z
  173. else if z=1 then nil . dump
  174. else for each trm in cdr z collect
  175. mod!-index(trm,dump) )
  176. propagator(l1,l2)$
  177. symbolic procedure dvertex!-to!-projector(svert,rlst,dump)$
  178. begin
  179. scalar l1,l2,coeff,w$
  180. l1:=mktails(cadr svert,rlst,dump)$
  181. if repeatsp car l1 then return 0$
  182. l2:= mktails(caddr svert,rlst,cdr l1)$
  183. if repeatsp car l2 then return 0$
  184. dump:=cdr l2$
  185. w:=prop!-simp(car l1,sreverse car l2)$
  186. coeff:=mk!-contract!-coeff w$
  187. return coeff . dpropagator(cadr w,cddr w,dump)
  188. end$
  189. %SYMBOLIC PROCEDURE DSTR!-TO!-ALG(STRAND,RLST,DUMP)$
  190. %IF NULL STRAND THEN LIST('RECIP,MK!-COEFF1(DUMP,RLST))
  191. %ELSE
  192. % BEGIN
  193. % SCALAR VRTX$
  194. % VRTX:=DVERTEX!-TO!-PROJECTOR(CAR STRAND,RLST,DUMP)$
  195. % IF 0=VRTX THEN RETURN 0$
  196. % IF NULL CADR VRTX THEN RETURN
  197. % LIST('TIMES,CAR VRTX,DSTR!-TO!-ALG(CDR STRAND,RLST,CDDR VRTX))$
  198. %
  199. % RETURN LIST('TIMES,CAR VRTX,
  200. % 'PLUS . (FOR EACH TRM IN CDR VRTX COLLECT
  201. % LIST('TIMES,CAR TRM,DSTR!-TO!-ALG(CDR STRAND,RLST,CDR TRM))) )
  202. %===MODYFIED 4.07.89
  203. remflag('(dstr!-to!-alg),'lose)$
  204. symbolic procedure dstr!-to!-alg(strand,rlst,dump)$
  205. %IF NULL STRAND THEN LIST('RECIP,MK!-COEFF1(DUMP,RLST))
  206. if null strand then consrecip list(mk!-coeff1(dump,rlst))
  207. else
  208. begin
  209. scalar vrtx$
  210. vrtx:=dvertex!-to!-projector(car strand,rlst,dump)$
  211. if 0=vrtx then return 0$
  212. if null cadr vrtx then return
  213. if 1 = car(vrtx) then
  214. dstr!-to!-alg(cdr strand,rlst,cddr vrtx)
  215. else
  216. cvitimes2(car vrtx,
  217. dstr!-to!-alg(cdr strand,rlst,cddr vrtx))$
  218. return
  219. cvitimes2(car vrtx,
  220. consplus (for each trm in cdr vrtx collect
  221. cvitimes2(car trm,
  222. dstr!-to!-alg(cdr strand,rlst,
  223. cdr trm))))$
  224. end$
  225. flag('(dstr!-to!-alg),'lose)$
  226. symbolic procedure cvitimes2(x,y)$
  227. if (x=0) or (y=0) then 0
  228. else if x = 1 then y
  229. else if y = 1 then x
  230. else list('times,x,y)$
  231. symbolic procedure free dlt$
  232. (freeind cadr dlt) and (freeind caddr dlt)$
  233. symbolic procedure freeind ind$
  234. atom ind $
  235. % AND
  236. %LAGP(IND,'EXTRNL)$
  237. symbolic procedure mod!-dump(l,dump)$
  238. if not freeind car l then mod!-dump1(cadr l,car l,dump)
  239. else mod!-dump1(car l,cadr l,dump)$
  240. symbolic procedure mod!-dump1(new,old,dump)$
  241. if null dump then nil
  242. else ( (caar dump) . l!-subst(new,old,cdar dump) ) .
  243. mod!-dump1(new,old,cdr dump)$
  244. symbolic procedure l!-subst(new,old,l)$
  245. if null l then nil
  246. else if old = car l then new . l!-subst(new,old,cdr l)
  247. else car l . l!-subst(new,old,cdr l) $
  248. endmodule;
  249. end;