pmrules.log 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533
  1. Codemist Standard Lisp 3.54 for DEC Alpha: May 23 1994
  2. Dump file created: Mon May 23 10:39:11 1994
  3. REDUCE 3.5, 15-Oct-93 ...
  4. Memory allocation: 6023424 bytes
  5. +++ About to read file tstlib.red
  6. *** ~ already defined as operator
  7. % Tests of PM.
  8. % TESTS OF BASIC CONSTRUCTS.
  9. operator f, h$
  10. % A "literal" template.
  11. m(f(a),f(a));
  12. t
  13. % Not literally equal.
  14. m(f(a),f(b));
  15. %Nested operators.
  16. m(f(a,h(b)),f(a,h(b)));
  17. t
  18. % A "generic" template.
  19. m(f(a,b),f(a,?a));
  20. {?a->b}
  21. m(f(a,b),f(?a,?b));
  22. {?a->a,?b->b}
  23. % ??a takes "rest" of arguments.
  24. m(f(a,b),f(??a));
  25. {??a->[a,b]}
  26. % But ?a does not.
  27. m(f(a,b),f(?a));
  28. % Conditional matches.
  29. m(f(a,b),f(?a,?b _=(?a=?b)));
  30. m(f(a,a),f(?a,?b _=(?a=?b)));
  31. {?a->a,?b->a}
  32. % "plus" is symmetric.
  33. m(a+b+c,c+?a+?b);
  34. {?a->a,?b->b}
  35. %It is also associative.
  36. m(a+b+c,c+?a);
  37. {?a->a + b}
  38. % Note the effect of using multi-generic symbol is different.
  39. m(a+b+c,c+??c);
  40. {??c->[a,b]}
  41. %Flag h as associative.
  42. flag('(h),'assoc);
  43. m(h(a,b,d,e),h(?a,d,?b));
  44. {?a->h(a,b),?b->e}
  45. % Substitution tests.
  46. s(f(a,b),f(a,?b)->?b^2);
  47. 2
  48. b
  49. s(a+b,a+b->a*b);
  50. a*b
  51. % "associativity" is used to group a+b+c in to (a+b) + c.
  52. s(a+b+c,a+b->a*b);
  53. a*b + c
  54. % Only substitute top at top level.
  55. s(a+b+f(a+b),a+b->a*b,inf,0);
  56. f(a + b) + a*b
  57. % SIMPLE OPERATOR DEFINITIONS.
  58. % Numerical factorial.
  59. operator nfac$
  60. s(nfac(3),{nfac(0)->1,nfac(?x)->?x*nfac(?x-1)},1);
  61. 3*nfac(2)
  62. s(nfac(3),{nfac(0)->1,nfac(?x)->?x*nfac(?x-1)},2);
  63. 6*nfac(1)
  64. si(nfac(3),{nfac(0)->1,nfac(?x)->?x*nfac(?x-1)});
  65. 6
  66. % General factorial.
  67. operator gamma,fac;
  68. fac(?x _=Natp(?x)) ::- ?x*fac(?x-1);
  69. hold(?x*fac(?x - 1))
  70. fac(0) :- 1;
  71. 1
  72. fac(?x) :- Gamma(?x+1);
  73. gamma(?x + 1)
  74. fac(3);
  75. 6
  76. fac(3/2);
  77. 5
  78. gamma(---)
  79. 2
  80. % Legendre polynomials in ?x of order ?n, ?n a natural number.
  81. operator legp;
  82. legp(?x,0) :- 1;
  83. 1
  84. legp(?x,1) :- ?x;
  85. ?x
  86. legp(?x,?n _=natp(?n))
  87. ::- ((2*?n-1)*?x*legp(?x,?n-1)-(?n-1)*legp(?x,?n-2))/?n;
  88. (2*?n - 1)*?x*legp(?x,?n - 1) - (?n - 1)*legp(?x,?n - 2)
  89. hold(----------------------------------------------------------)
  90. ?n
  91. legp(z,5);
  92. 4 2
  93. z*(63*z - 70*z + 15)
  94. ------------------------
  95. 8
  96. legp(a+b,3);
  97. 3 2 2 3
  98. 5*a + 15*a *b + 15*a*b - 3*a + 5*b - 3*b
  99. ---------------------------------------------
  100. 2
  101. legp(x,y);
  102. legp(x,y)
  103. % TESTS OF EXTENSIONS TO BASIC PATTERN MATCHER.
  104. comment *: MSet[?exprn,?val] or ?exprn ::: ?val
  105. assigns the value ?val to the projection ?exprn in such a way
  106. as to store explicitly each form of ?exprn requested. *;
  107. Nosimp('mset,(t t));
  108. Newtok '((!: !: !: !-) Mset);
  109. infix :::-;
  110. precedence Mset,RSetd;
  111. ?exprn :::- ?val ::- (?exprn ::- (?exprn :- ?val ));
  112. hold(?exprn::-(?exprn:-?val))
  113. scs := sin(?x)^2 + Cos(?x)^2 -> 1;
  114. 2 2
  115. scs := cos(?x) + sin(?x) ->1
  116. % The following pattern substitutes the rule sin^2 + cos^2 into a sum of
  117. % such terms. For 2n terms (ie n sin and n cos) the pattern has a worst
  118. % case complexity of O(n^3).
  119. operator trig,u;
  120. trig(?i) :::- Ap(+, Ar(?i,sin(u(?1))^2+Cos(u(?1))^2));
  121. 2 2
  122. hold(trig(?i):-ap(plus,ar(?i,sin(u(?1)) + cos(u(?1)) )))
  123. if si(trig 1,scs) = 1 then write("Pm ok") else Write("PM failed");
  124. Pm ok
  125. if si(trig 10,scs) = 10 then write("Pm ok") else Write("PM failed");
  126. Pm ok
  127. % The next one takes about 70 seconds on an HP 9000/350, calling UNIFY
  128. % 1927 times.
  129. % if si(trig 50,scs) = 50 then write("Pm ok") else Write("PM failed");
  130. % Hypergeometric Function simplification.
  131. newtok '((!#) !#);
  132. *** # redefined
  133. flag('(#), 'symmetric);
  134. operator #,@,ghg;
  135. xx := ghg(4,3,@(a,b,c,d),@(d,1+a-b,1+a-c),1);
  136. xx := ghg(4,3,@(a,b,c,d),@(d,a - b + 1,a - c + 1),1)
  137. S(xx,sghg(3));
  138. *** sghg declared operator
  139. ghg(4,3,@(a,b,c,d),@(d,a - b + 1,a - c + 1),1)
  140. s(ws,sghg(2));
  141. ghg(4,3,@(a,b,c,d),@(d,a - b + 1,a - c + 1),1)
  142. yy := ghg(3,2,@(a-1,b,c/2),@((a+b)/2,c),1);
  143. c a + b
  144. yy := ghg(3,2,@(a - 1,b,---),@(-------,c),1)
  145. 2 2
  146. S(yy,sghg(1));
  147. c a + b
  148. ghg(3,2,@(a - 1,b,---),@(-------,c),1)
  149. 2 2
  150. yy := ghg(3,2,@(a-1,b,c/2),@(a/2+b/2,c),1);
  151. c a + b
  152. yy := ghg(3,2,@(a - 1,b,---),@(-------,c),1)
  153. 2 2
  154. S(yy,sghg(1));
  155. c a + b
  156. ghg(3,2,@(a - 1,b,---),@(-------,c),1)
  157. 2 2
  158. % Some Ghg theorems.
  159. flag('(@), 'symmetric);
  160. % Watson's Theorem.
  161. SGhg(1) := Ghg(3,2,@(?a,?b,?c),@(?d _=?d=(1+?a+?b)/2,?e _=?e=2*?c),1) ->
  162. Gamma(1/2)*Gamma(?c+1/2)*Gamma((1+?a+?b)/2)*Gamma((1-?a-?b)/2+?c)/
  163. (Gamma((1+?a)/2)*Gamma((1+?b)/2)*Gamma((1-?a)/2+?c)
  164. *Gamma((1-?b)/2+?c));
  165. sghg(1) := ghg(3,2,@(?a,?b,?c),
  166. 1 + ?a + ?b
  167. @(?d _= ?d=-------------,?e _= ?e=2*?c),1)->(
  168. 2
  169. - ?a - ?b + 2*?c + 1 2*?c + 1
  170. gamma(-----------------------)*gamma(----------)
  171. 2 2
  172. ?a + ?b + 1 1
  173. *gamma(-------------)*gamma(---))/(
  174. 2 2
  175. - ?a + 2*?c + 1 - ?b + 2*?c + 1
  176. gamma(------------------)*gamma(------------------)
  177. 2 2
  178. ?a + 1 ?b + 1
  179. *gamma(--------)*gamma(--------))
  180. 2 2
  181. % Dixon's theorem.
  182. SGhg(2) := Ghg(3,2,@(?a,?b,?c),@(?d _=?d=1+?a-?b,?e _=?e=1+?a-?c),1) ->
  183. Gamma(1+?a/2)*Gamma(1+?a-?b)*Gamma(1+?a-?c)*Gamma(1+?a/2-?b-?c)/
  184. (Gamma(1+?a)*Gamma(1+?a/2-?b)*Gamma(1+?a/2-?c)*Gamma(1+?a-?b-?c));
  185. sghg(2) := ghg(3,2,@(?a,?b,?c),
  186. @(?d _= ?d=1 + ?a - ?b,?e _= ?e=1 + ?a - ?c),1)->(
  187. gamma(?a - ?b + 1)*gamma(?a - ?c + 1)
  188. ?a - 2*?b - 2*?c + 2 ?a + 2
  189. *gamma(----------------------)*gamma(--------))/(
  190. 2 2
  191. gamma(?a - ?b - ?c + 1)*gamma(?a + 1)
  192. ?a - 2*?b + 2 ?a - 2*?c + 2
  193. *gamma(---------------)*gamma(---------------))
  194. 2 2
  195. SGhg(3) := Ghg(?p,?q,@(?a,??b),@(?a,??c),?z)
  196. -> Ghg(?p-1,?q-1,@(??b),@(??c),?z);
  197. sghg(3) := ghg(?p,?q,@(??b,?a),@(??c,?a),?z)
  198. ->ghg(?p - 1,?q - 1,@(??b),@(??c),?z)
  199. SGhg(9) := Ghg(1,0,@(?a),?b,?z ) -> (1-?z)^(-?a);
  200. 1
  201. sghg(9) := ghg(1,0,@(?a),?b,?z)->---------------
  202. ?a
  203. ( - ?z + 1)
  204. SGhg(10) := Ghg(0,0,?a,?b,?z) -> E^?z;
  205. ?z
  206. sghg(10) := ghg(0,0,?a,?b,?z)->e
  207. SGhg(11) := Ghg(?p,?q,@(??t),@(??b),0) -> 1;
  208. sghg(11) := ghg(?p,?q,@(??t),@(??b),0)->1
  209. % If one of the bottom parameters is zero or a negative integer the
  210. % hypergeometric functions may be singular, so the presence of a
  211. % functions of this type causes a warning message to be printed.
  212. % Note it seems to have an off by one level spec., so this may need
  213. % changing in future.
  214. %
  215. % Reference: AS 15.1; Slater, Generalized Hypergeometric Functions,
  216. % Cambridge University Press,1966.
  217. s(Ghg(3,2,@(a,b,c),@(b,c),z),SGhg(3));
  218. ghg(2,1,@(a,b),@(b),z)
  219. si(Ghg(3,2,@(a,b,c),@(b,c),z),{SGhg(3),Sghg(9)});
  220. 1
  221. -------------
  222. a
  223. ( - z + 1)
  224. S(Ghg(3,2,@(a-1,b,c),@(a-b,a-c),1),sghg 2);
  225. a - 2*b - 2*c + 1 a + 1
  226. gamma(a - b)*gamma(a - c)*gamma(-------------------)*gamma(-------)
  227. 2 2
  228. ---------------------------------------------------------------------
  229. a - 2*b + 1 a - 2*c + 1
  230. gamma(a - b - c)*gamma(-------------)*gamma(-------------)*gamma(a)
  231. 2 2
  232. end;
  233. (pmrules 2283 0)
  234. End of Lisp run after 2.29+0.91 seconds