mtables.red 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478
  1. % Description: This file contains the tables guiding the program
  2. %
  3. % Version 26 March 2000
  4. %
  5. % Author: Luis Alvarez Sobreviela
  6. %
  7. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  8. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  9. % Declaration of a series of table lists which contain the function to be executed %
  10. % when a certain token is encountered. %
  11. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  12. constants!*:=
  13. '(!&true!; !&false!; !&imaginaryi!; !&ii!; !&exponentiale!; !&ee!; !&pi!; !&infin!; !&gamma!; !&differentiald!;
  14. !&dd!;);
  15. % The relations!* list contains the correspondance between
  16. % tokens to be found between <reln></reln> tags and the
  17. % reduce function to be executed as well as the argument
  18. % the reduce function should take.
  19. % The <reln> tag is deprecated in MathML2.0 but we have
  20. % kept it for backwards compatibilty.
  21. relations!*:=
  22. '((tendsto . (binaryRD tendsto))
  23. (tendsto!/ . (binaryRD tendsto))
  24. (eq!/ . (naryRD eq))
  25. (neq!/ . (binaryRD neq))
  26. (lt!/ . (naryRD lt))
  27. (gt!/ . (naryRD gt))
  28. (geq!/ . (naryRD geq))
  29. (leq!/ . (naryRD leq))
  30. (in!/ . (binaryRD in))
  31. (notin!/ . (binaryRD notin))
  32. (subset!/ . (subsetrd subset))
  33. (prsubset!/ . (prsubsetrd prsubset))
  34. (notprsubset!/ . (binaryRD notprsubset))
  35. (notsubset!/ . (binaryRD notsubset)));
  36. % The functions!* list contains the correspondance between
  37. % tokens to be found between <apply></apply> tags and the
  38. % reduce function to be executed as well as the argument
  39. % the reduce function should take.
  40. functions!*:=
  41. '((divide!/ . (binaryRD divide))
  42. (scalarproduct!/ . (binaryRD scalarproduct))
  43. (vectorproduct!/ . (binaryRD vectorproduct))
  44. (outerproduct!/ . (binaryRD outerproduct))
  45. (divergence!/ . (unaryRD divergence))
  46. (curl!/ . (unaryRD curl))
  47. (laplacian!/ . (unaryRD laplacian))
  48. (grad!/ . (unaryRD grad))
  49. (size!/ . (unaryRD size))
  50. (setdiff!/ . (setFuncsBinRD setdiff))
  51. (select!/ . (selectRD selector))
  52. (selector!/ . (selectRD selector))
  53. (transpose!/ . (transposeRD transpose))
  54. (determinant!/ . (determinantRD determinant))
  55. (fn . (applyfnRD fn))
  56. (union!/ . (setFuncsnaryRD union))
  57. (intersect!/ . (setFuncsnaryRD intersect))
  58. (implies!/ . (binaryRD implies))
  59. (not!/ . (unaryRD not))
  60. (xor!/ . (naryRD xor))
  61. (or!/ . (naryRD or))
  62. (and!/ . (naryRD and))
  63. (mean!/ . (naryRD mean))
  64. (mode!/ . (naryRD mode))
  65. (var!/ . (naryRD variance))
  66. (variance!/ . (naryRD var))
  67. (sdev!/ . (naryRD sdev))
  68. (moment!/ . (momentRD moment))
  69. (median!/ . (naryRD median))
  70. (sin!/ . (unaryRD sin))
  71. (sec!/ . (unaryRD sec))
  72. (sinh!/ . (unaryRD sinh))
  73. (sech!/ . (unaryRD sech))
  74. (arcsin!/ . (unaryRD arcsin))
  75. (cos!/ . (unaryRD cos))
  76. (csc!/ . (unaryRD csc))
  77. (cosh!/ . (unaryRD cosh))
  78. (csch!/ . (unaryRD csch))
  79. (arccos!/ . (unaryRD arccos))
  80. (tan!/ . (unaryRD tan))
  81. (cot!/ . (unaryRD cot))
  82. (tanh!/ . (unaryRD tanh))
  83. (coth!/ . (unaryRD coth))
  84. (arctan!/ . (unaryRD arctan))
  85. (abs!/ . (unaryRD abs))
  86. (ln!/ . (unaryRD ln))
  87. (plus!/ . (naryRD plus))
  88. (times!/ . (naryRD times))
  89. (power!/ . (binaryRD power))
  90. (exp!/ . (unaryRD exp))
  91. (factorial!/ . (unaryRD factorial))
  92. (quotient!/ . (binaryRD quotient))
  93. (max!/ . (minmaxRD max))
  94. (min!/ . (minmaxRD min))
  95. (minus!/ . (minusRD minus))
  96. (rem!/ . (binaryRD rem))
  97. (conjugate!/ . (unaryRD conjugate))
  98. (root!/ . (rootRD root))
  99. (gcd!/ . (naryRD gcd))
  100. (log!/ . (logRD log))
  101. (int!/ . (symbolsRD int))
  102. (sum!/ . (symbolsRD sum))
  103. (limit!/ . (limitRD limit))
  104. (condition . (conditionRD condition))
  105. (product!/ . (symbolsRD product))
  106. (diff!/ . (diffRD diff))
  107. (partialdiff!/ . (partialdiffRD partialdiff))
  108. (inverse!/ . (unaryRD inverse))
  109. (tendsto . (binaryRD tendsto))
  110. (tendsto!/ . (binaryRD tendsto))
  111. (eq!/ . (naryRD eq))
  112. (neq!/ . (binaryRD neq))
  113. (lt!/ . (naryRD lt))
  114. (gt!/ . (naryRD gt))
  115. (geq!/ . (naryRD geq))
  116. (leq!/ . (naryRD leq))
  117. (in!/ . (setFuncsBinRD in))
  118. (notin!/ . (setFuncsBinRD notin))
  119. (subset!/ . (subsetrd subset))
  120. (prsubset!/ . (prsubsetrd prsubset))
  121. (notprsubset!/ . (setFuncaBinRD notprsubset))
  122. (notsubset!/ . (setFuncsBinRD notsubset))
  123. (forall!/ . (quantifierRD forall))
  124. (exists!/ . (quantifierRD exists))
  125. (equivalent!/ . (binaryRD equivalent))
  126. (approx!/ . (binaryRD approx))
  127. (imaginary!/ . (unaryRD imaginary))
  128. (real!/ . (unaryRD real))
  129. (arg!/ . (unaryRD arg))
  130. (compose!/ . (naryRD compose))
  131. (csymbol . (csymbolrd csymbol)));
  132. % The constructors!* list sets a correspondance between MathML
  133. % constructor tags, the reduce function to be executed and the
  134. % closing tag which must be looked for in order to make sure
  135. % syntax is correct
  136. constructors!* :=
  137. '((reln . (relnRD !/reln "</reln>"))
  138. (set . ( setRD !/set "</set>"))
  139. (fn . ( fnRD !/fn "</fn>"))
  140. (declare . ( declareRD !/declare "</declare>"))
  141. (interval . ( intervalRD !/interval "</interval>"))
  142. (list . ( listRD !/list "</list>"))
  143. (matrix . ( matrixRD !/matrix "</matrix>"))
  144. (apply . ( applyRD !/apply "</apply>"))
  145. (cn . ( cnRD !/cn "</cn>"))
  146. (ci . ( ciRD !/ci "</ci>"))
  147. (lambda . ( lambdaRD !/lambda "</lambda>")));
  148. % The mml!* list determines the correspondance between elements
  149. % in the intermediate representation and the reduce functions to be
  150. % executed.
  151. % The ir2mml!* table determines what function to execute for each
  152. % element of the intermediate representation.
  153. % Its syntax is the following:
  154. %
  155. % (ir_element . (reduce_function function_argument))
  156. %
  157. % The function argument is the equvalent MathML tag usually
  158. ir2mml!* :=
  159. '((determinant . (nary determinant naryOM))
  160. (semantic . (semanticML nil semanticOM))
  161. (string . (nil nil strOM))
  162. (based_integer . (numML based_integer naryOM))
  163. (complex_cartesian . (numML complex_cartesian naryOM))
  164. (complex_polar . (numML complex_polar naryOM))
  165. (ci . (ciML nil ciOM))
  166. (cn . (cnML nil cnOM))
  167. (vectorml . (vectorML nil containerOM))
  168. (scalarproduct . (nary scalarproduct naryOM))
  169. (vectorproduct . (nary vectorproduct naryOM))
  170. (outerproduct . (nary outerproduct naryOM))
  171. (lambda . (containerML lambda lambdaOM))
  172. (declare . (declareML nil))
  173. (divergence . (nary divergence naryOM))
  174. (laplacian . (nary laplacian naryOM))
  175. (curl . (nary curl naryOM))
  176. (grad . (nary grad naryOM))
  177. (size . (nary size naryOM))
  178. (moment . (degreetoksML moment naryOM))
  179. (transpose . (nary transpose naryOM))
  180. (sum . (nary sum symbolsOM))
  181. (product . (nary product symbolsOM))
  182. (limit . (nary limit limitOM))
  183. (tendsto . (tendstoML nil))
  184. (df . (dfML nil))
  185. (diff . (nary diff symbolsOM))
  186. (partialdiff . (nary partialdiff partialdiffOM))
  187. (conjugate . (nary conjugate naryOM))
  188. (inverse . (nary inverse naryOM))
  189. (abs . (nary abs naryOM))
  190. (gcd . (nary gcd naryOM))
  191. (set . (containerML set containerOM))
  192. (factorial . (nary factorial naryOM))
  193. (max . (nary max naryOM))
  194. (min . (nary min naryOM))
  195. (and . (nary and naryOM))
  196. (or . (nary or naryOM))
  197. (xor . (nary xor naryOM))
  198. (selector . (nary selector selectOM))
  199. (cos . (nary cos naryOM))
  200. (sin . (nary sin naryOM))
  201. (sec . (nary sec naryOM))
  202. (cosh . (nary cosh naryOM))
  203. (cot . (nary cot naryOM))
  204. (coth . (nary coth naryOM))
  205. (csch . (nary csch naryOM))
  206. (arccos . (nary arccos naryOM))
  207. (arcsin . (nary arcsin naryOM))
  208. (arctan . (nary arctan naryOM))
  209. (sech . (nary sech naryOM))
  210. (sinh . (nary sinh naryOM))
  211. (tan . (nary tan naryOM))
  212. (tanh . (nary tanh naryOM))
  213. (csc . (nary csc naryOM))
  214. (arg . (nary arg naryOM))
  215. (real . (nary real naryOM))
  216. (exp . (nary exp naryOM))
  217. (not . (nary not naryOM))
  218. (rem . (nary rem naryOM))
  219. (imaginary . (nary imaginary naryOM))
  220. (quotient . (quotientML quotient naryOM))
  221. (divide . (quotientML divide naryOM))
  222. (equivalent . (nary equivalent naryOM))
  223. (approx . (nary approx naryOM))
  224. (implies . (nary implies naryOM))
  225. (plus . (nary plus naryOM))
  226. (times . (nary times naryOM))
  227. (power . (nary power naryOM))
  228. (median . (nary median naryOM))
  229. (mean . (nary mean naryOM))
  230. (sdev . (nary sdev naryOM))
  231. (variance . (nary variance naryOM))
  232. (mode . (nary mode naryOM))
  233. (compose . (nary compose naryOM))
  234. (root . (degreetoksML root naryOM))
  235. (log . (log_baseML log naryOM))
  236. (logb . (log_baseML logb))
  237. (log10 . (log_baseML log10))
  238. (ln . (nary ln naryOM))
  239. (eq . (reln eq naryOM))
  240. (neq . (reln neq naryOM))
  241. (gt . (reln gt naryOM))
  242. (lt . (reln lt naryOM))
  243. (geq . (reln geq naryOM))
  244. (leq . (reln leq naryOM))
  245. (union . (sets union naryOM))
  246. (intersect . (sets intersect naryOM))
  247. (in . (reln in naryOM))
  248. (notin . (reln notin naryOM))
  249. (subset . (reln subset naryOM))
  250. (prsubset . (reln prsubset naryOM))
  251. (notsubset . (reln notsubset naryOM))
  252. (notprsubset . (reln notprsubset naryOM))
  253. (setdiff . (sets setdiff naryOM))
  254. (rational . (rationalML nil naryOM))
  255. (matrix . (matrixML nil matrixOM))
  256. (minus . (minusML nil naryOM))
  257. (int . (nary int symbolsOM))
  258. (equal . (equalML nil naryOM))
  259. (bvar . (bvarML nil))
  260. (degree . (degreeML nil))
  261. (interval . (containerML interval intervalOM))
  262. (integer_interval . (containerML interval intervalOM))
  263. (condition . (conditionML nil))
  264. (lowupperlimit . (lowupperlimitML nil intervalOM))
  265. (lowlimit . (lowlimitML nil))
  266. (fn . (csymbol_fn nil))
  267. %Ident has no OpenMath equivalent
  268. (ident . (identML nil))
  269. (forall . (nary forall quantOM))
  270. (exists . (nary exists quantOM))
  271. (list . (containerML list containerOM)));
  272. % This table contains all the OpenMath elements which are understood by the
  273. % translator and which have a MathML equivalent. The symbol and originating CDs
  274. % are contained in this table.
  275. valid_om!*:=
  276. '((divide . (arith1))
  277. (integer (omtypes))
  278. (float (omtypes))
  279. (selector .(linalg3))
  280. (complex_cartesian . (nums1))
  281. (complex_polar . (nums1))
  282. (based_integer . (nums1))
  283. (equivalent . (logic2))
  284. (approx . (relation2))
  285. (determinant . (linalg3))
  286. (transpose . (linalg3))
  287. (inverse . (fns1 arith2))
  288. (in . (set1 multiset1))
  289. (subset . (set1 multiset1))
  290. (prsubset . (set1 multiset1))
  291. (notsubset . (set1 multiset1))
  292. (notprsubset . (set1 multiset1))
  293. (set . (set1 multiset1))
  294. (setdiff . (set1 multiset1))
  295. (union . (set1 multiset1))
  296. (notin . (set1 multiset1))
  297. (intersect . (set1 multiset1))
  298. (implies . (logic1))
  299. (not . (logic1))
  300. (xor . (logic1))
  301. (vectorproduct . (linalg1))
  302. (vector . (linalg1 linalg2))
  303. (or . (logic1))
  304. (forall . (quant1))
  305. (and . (logic1))
  306. (mean . (stats1))
  307. (mode . (stats1))
  308. (variance . (stats1))
  309. (sdev . (stats1))
  310. (moment . (stats1))
  311. (median . (stats1))
  312. (sin . (transc1))
  313. (sinh . (transc1))
  314. (arcsin . (transc1))
  315. (arcsinh . (transc1 transc2))
  316. (sec . (transc1))
  317. (sech . (transc1))
  318. (arcsec . (transc1 transc2))
  319. (arcsech . (transc1 transc2))
  320. (cos . (transc1))
  321. (arccos . (transc1))
  322. (cosh . (transc1))
  323. (arccosh . (transc1 arctrans2))
  324. (csc . (transc1))
  325. (csch . (transc1))
  326. (arccsc . (transc1 transc2))
  327. (arccsch . (transc1 transc2))
  328. (tan . (transc1))
  329. (tanh . (transc1))
  330. (arctan . (transc1))
  331. (arctanh . (transc1 transc2))
  332. (cot . (transc1))
  333. (coth . (transc1))
  334. (arccot . (transc1 transc2))
  335. (arccoth . (transc1 transc2))
  336. (ln . (transc1))
  337. (exp . (transc1))
  338. (abs . (arith1))
  339. (plus . (arith1))
  340. (times . (arith1 arith2))
  341. (power . (arith1))
  342. (factorial . (integer1))
  343. (minus . (arith1))
  344. (rem . (integer1))
  345. (conjugate . (arith1))
  346. (root . (arith1))
  347. (log . (transc1))
  348. (int . (calculus1))
  349. (gcd . (integer1))
  350. (quotient . (integer1))
  351. (sum . (arith1))
  352. (product . (arith1))
  353. (scalarproduct . (linalg1))
  354. (outerproduct . (linalg1))
  355. (diff . (calculus1))
  356. (partialdiff . (calculus1))
  357. (eq . (relation1))
  358. (neq . (relation1))
  359. (leq . (relation1))
  360. (geq . (relation1))
  361. (lt . (relation1))
  362. (gt . (relation1))
  363. (quotient . (integer1))
  364. (interval . (interval1))
  365. (integer_interval . (interval1))
  366. (min . (minmax1))
  367. (max . (minmax1))
  368. (imaginary . (nums1))
  369. (real . (nums1))
  370. (forall . (quant1))
  371. (exists . (quant1))
  372. (lambda . (fns1))
  373. (list . (list1))
  374. (arg . (arith2))
  375. (type . (typmml))
  376. (rational . (nums1))
  377. (curl . (veccalc1))
  378. (divergence . (veccalc1))
  379. (grad . (veccalc1))
  380. (size . (linalg3))
  381. (laplacian . (veccalc1)));
  382. % The following table keeps information about OpenMath elements which have
  383. % a MathML equivalent, but with another name. It also makes sure that
  384. % the MathML translation has the correct attributes when attributes
  385. % are needed to have a correct semantic translation.
  386. %
  387. % The format of the table is:
  388. % (OpenMath_symbol_name . (one_or_more_CDs MathML_equivalent MathML_attribute))
  389. special_cases!*:=
  390. '((unary_minus . (arith1 minus nil))
  391. (both_sides . (limit1 nil nil))
  392. (above . (limit1 tendsto above))
  393. (below . (limit1 tendsto below))
  394. (null . (limit1 nil nil))
  395. (multiset . (multiset1 set (type multiset)))
  396. (complex_cartesian_type . (typmml complex_cartesian nil))
  397. (complex_polar_type . (typmml complex_polar nil))
  398. (constant_type . (typmml constant nil))
  399. (fn_type . (typmml csymbol nil))
  400. (integer_type . (typmml integer nil))
  401. (list_type . (typmml list nil))
  402. (matrix_type . (typmml matrix nil))
  403. (rational_type . (typmml rational nil))
  404. (real_type . (typmml real nil))
  405. (set_type . (typmml set nil))
  406. (vector_type . (typmml vectorml nil))
  407. (integer_interval . (interval1 interval nil))
  408. (interval_oo . (interval1 interval (closure open)))
  409. (interval_cc . (interval1 interval (closure close)))
  410. (interval_oc . (interval1 interval (closure open!-closed)))
  411. (interval_co . (interval1 interval (closure closed!-open))));
  412. % The following table specifies when it is
  413. % necessary to call a function to deal in a
  414. % precise way with the translation of the
  415. % symbol.
  416. special_cases2!*:=
  417. '((matrix . (matrixIR))
  418. (limit . (limitIR))
  419. (vector_selector . (selectIR))
  420. (matrix_selector . (selectIR))
  421. (complex_cartesian . (numIR))
  422. (complex_polar . (numIR))
  423. (rational . (numIR))
  424. (defint . (integralIR))
  425. (int . (integralIR))
  426. (diff . (integralIR))
  427. (partialdiff . (partialdiffIR))
  428. (sum . (sum_prodIR))
  429. (product . (sum_prodIR))
  430. (one . (unaryIR alg1 1))
  431. (zero . (unaryIR alg1 0))
  432. (i . (unaryIR nums1 !&ImaginaryI!;))
  433. (e . (unaryIR nums1 !&ExponentialE!;))
  434. (pi . (unaryIR nums1 !&pi!;))
  435. (nan . (unaryIR nums1 !&NotANumber!;))
  436. (gamma . (unaryIR nums1 !&gamma!;))
  437. (infinity . (unaryIR nums1 !&infin!;))
  438. (false . (unaryIR logic1 !&false!;))
  439. (true . (unaryIR logic1 !&true!;)));
  440. % This table contains the OpenMath elements which map simply to MathML.
  441. % These symbols have direct mapping into MathML.
  442. mmleq!*:= '(divide based_integer
  443. equivalent approx determinant transpose inverse in subset prsubset
  444. notsubset notprsubset set setdiff union notin intersect implies not xor
  445. vectorproduct vector or forall and mean mode variance sdev moment median
  446. sin sinh arcsin arcsinh sec sech arcsec arcsech cos arccos cosh arccosh
  447. csc csch arccsc arccsch tan tanh arctan arctanh cot coth arccot arccoth
  448. ln exp abs plus times power factorial minus rem conjugate root log gcd
  449. quotient scalarproduct outerproduct eq neq leq geq lt gt quotient
  450. interval min max imaginary real forall exists lambda list arg type
  451. laplacian divergence curl grad size integer);
  452. end;