ofsf.red 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572
  1. % ----------------------------------------------------------------------
  2. % $Id: ofsf.red,v 1.24 1999/03/23 12:26:33 sturm Exp $
  3. % ----------------------------------------------------------------------
  4. % Copyright (c) 1995-1999 Andreas Dolzmann and Thomas Sturm
  5. % ----------------------------------------------------------------------
  6. % $Log: ofsf.red,v $
  7. % Revision 1.24 1999/03/23 12:26:33 sturm
  8. % Renamed switch rlsisqf to rlsiatadv.
  9. %
  10. % Revision 1.23 1999/03/23 07:40:16 dolzmann
  11. % Changed copyright information.
  12. % Added list of exported procedures and import list.
  13. %
  14. % Revision 1.22 1999/03/21 13:37:18 dolzmann
  15. % Use cl_bnfsimpl instead of acfsf_bnfsimpl.
  16. % Removed black box rl_zero.
  17. %
  18. % Revision 1.21 1999/03/18 14:08:20 sturm
  19. % Added new service rl_specelim!* in cl_qe for covering the "super
  20. % quadratic special case' for ofsf. This method is toggled by switch
  21. % rlsqsc, which is off by default. Context dvfsf uses cl_specelim which
  22. % is constantly "false." Context acfsf does not use cl_qe at all.
  23. %
  24. % Revision 1.20 1998/04/09 11:00:03 sturm
  25. % Added switch rlqeqsc for quadratic special case. This now OFF by default!
  26. %
  27. % Revision 1.19 1997/08/24 16:18:50 sturm
  28. % Added service rl_surep with black box rl_multsurep.
  29. % Added service rl_siaddatl.
  30. %
  31. % Revision 1.18 1997/08/14 10:10:30 sturm
  32. % Renamed rldecdeg to rldecdeg1.
  33. % Added service rldecdeg.
  34. %
  35. % Revision 1.17 1997/08/13 12:44:38 dolzmann
  36. % Introduced service rldecdeg.
  37. %
  38. % Revision 1.16 1996/10/23 11:24:48 dolzmann
  39. % Added procedure ofsf_mkstrict.
  40. %
  41. % Revision 1.15 1996/10/20 15:54:57 sturm
  42. % Added switches rlnzden, rlposden, and rladdcond and corresponding code
  43. % handling the input of reciprocal terms.
  44. %
  45. % Revision 1.14 1996/10/17 13:52:07 sturm
  46. % Introduced services rlvarl, rlfvarl, and rlbvarl. Renamed cl_varl to
  47. % cl_varl1 for this.
  48. %
  49. % Revision 1.13 1996/10/14 16:03:08 sturm
  50. % Declared !*rlqeheu fluid for the optimizer.
  51. %
  52. % Revision 1.12 1996/10/08 13:54:33 dolzmann
  53. % Renamed "degree parity decomposition" to "parity decomposition".
  54. % Adapted names of procedures and switches accordingly.
  55. %
  56. % Revision 1.11 1996/10/01 10:23:07 reiske
  57. % Added ofsf services rlqews and rlqeipo.
  58. % Introduced new service rltnf and related code.
  59. %
  60. % Revision 1.10 1996/09/30 16:55:30 sturm
  61. % Switched to new tableau code.
  62. %
  63. % Revision 1.9 1996/09/29 14:22:57 sturm
  64. % Introduced services rlqea and rlgqea.
  65. %
  66. % Revision 1.8 1996/09/26 11:48:55 dolzmann
  67. % Do not use T as formal parameter.
  68. %
  69. % Revision 1.7 1996/09/05 11:14:46 dolzmann
  70. % Introduced new switch !*rlqegenct.
  71. % Using cl black box implementation for black box rl_trygauss.
  72. % Introduced new black boxes rl_qefsolset, rl_bettergaussp!*, rl_bestgaussp,
  73. % rl_esetunion, rl_structat, rl_ifstructat, and rl_termmlat.
  74. % Introduced new services rl_ifacml, rl_struct, rl_ifstruct, rl_termml, and
  75. % rl_terml.
  76. % Added lost procedure ofsf_simpterm.
  77. %
  78. % Revision 1.6 1996/08/01 11:45:27 reiske
  79. % Added services rl_natab, rl_nitab, and rl_gentheo.
  80. % Added black boxes rl_a2cdl and rl_getineq.
  81. %
  82. % Revision 1.5 1996/07/13 11:09:33 dolzmann
  83. % Introduced new switches !*rlgsbnf and !*rlgsutord.
  84. % Using cl black box implementations for black boxes rl_smsimpl!-impl
  85. % and rl_smsimpl!-equiv1.
  86. %
  87. % Revision 1.4 1996/07/07 14:38:14 sturm
  88. % Introduced new service rl_nnfnot.
  89. % Introduced new black box rl_eqnrhskernels.
  90. %
  91. % Revision 1.3 1996/05/21 17:14:07 sturm
  92. % Added service rl_subfof and black boxes rl_subat, rl_subalchk.
  93. %
  94. % Revision 1.2 1996/05/12 08:27:19 sturm
  95. % Loading rltools now.
  96. % Introduced new switch rlsitsqspl.
  97. % Introduced internal switch !*rlqegen.
  98. % Removed context control for switch ezgcd.
  99. % Introduced new services rl_thsimpl and rl_gqe.
  100. %
  101. % Revision 1.1 1996/03/22 12:13:59 sturm
  102. % Moved and split.
  103. %
  104. % Revision 1.25 1996/03/18 15:46:31 sturm
  105. % Moved switch defaults to module rl.
  106. % Removed ofsf_enter, ofsf_exit, and ofsf_svezgcd!*. The ezgcd is treated
  107. % as context switch now.
  108. % Added service rl_atml.
  109. % Removed properties ofsf_prepfn from the ofsf predicates.
  110. % Removed properties "prepfnname", "prepdefault", "resimpfnname", and
  111. % "resimpdefault" from "ofsf."
  112. % Added property "rl_prepat" to "ofsf."
  113. % Added procedures ofsf_prepat, ofsf_resimpat, ofsf_lengthat,
  114. % Added service rl_atml.
  115. % Removed procedure ofsf_tordp.
  116. % Adapted black box implementation ofsf_fctrat: the content is dropped now.
  117. %
  118. % Revision 1.24 1996/03/11 13:19:23 reiske
  119. % Added black box implementations ofsf_fctrat and ofsf_tordp.
  120. %
  121. % Revision 1.23 1996/03/10 13:03:49 sturm
  122. % Added default setting for switch !*rlqeheu.
  123. % Added service rl_matrix.
  124. % Changed verbosity output in module ofsfqe.
  125. % Removed Gauss code that was commented out previously.
  126. %
  127. % Revision 1.22 1996/03/10 12:48:54 dolzmann
  128. % Set services rl_dnf to ofsf_dnf and rl_cnf to ofsf_cnf respectively.
  129. % Added procedures ofsf_dnf, ofsf_cnf. These procedures call
  130. % cl_cnf/cl_cnf with !*rlsiso on where necessary.
  131. % Introduced new switch !*rlgsvb and corresponding code. Groebner
  132. % simplifier gives verbosity output only with both !*rlverbose and
  133. % !*rlgsvb on.
  134. %
  135. % Revision 1.21 1996/03/09 13:36:02 sturm
  136. % Added switch rlqesr and corresponding code.
  137. % Renamed constructors:
  138. % ofsf_constr2 -> ofsf_mk2
  139. % ofsf_0constr2 -> ofsf_0mk2
  140. % ofsf_constrn -> ofsf_mkn
  141. % Changes in module ofsfqe:
  142. % Added procedures ofsf_qesubcr1, ofsf_qesubcrpe1 and ofsf_qesubcrme1.
  143. % Added parameter "ans" to procedures ofsf_translat, ofsf_trygauss, and
  144. % ofsf_findeqsol.
  145. % Fixed a bug in (former) ofsf_qemkans.
  146. % Added procedures ofsf_qemkans1 and ofsf_qebacksub for answer
  147. % back-substitution.
  148. %
  149. % Revision 1.20 1996/03/04 17:11:41 sturm
  150. % Added ofsf_enter, ofsf_exit, and fluid ofsf_svezgcd!* for turning on
  151. % ezgcd while in ofsf context.
  152. % Added black box implementations ofsf_transform, ofsf_updatr.
  153. % Fixed a bug in ofsf_qscp.
  154. % Added detection of formulas that are linear after factorization to
  155. % ofsf_varsel. The same for quadratic formulas.
  156. % Added handling of answer transformations to ofsf_qemkans.
  157. % Moved ofsf_reorder to module sfto.
  158. %
  159. % Revision 1.19 1996/03/04 13:09:19 dolzmann
  160. % Removed loading of groebner packages.
  161. % Added switch !*rlbnfsac.
  162. % Added black box implementations ofsf_bnfsimpl, ofsf_sacat, ofsf_sacatlp.
  163. % New module ofsf_bnf. Moved code for bnf computation from ofsf_below to
  164. % ofsf_bnf.
  165. % Turned off !*rlsiexpla with groebner simplifier
  166. % Moved procedures gs_groebnerf, gs_preducef, gs_greducef to module sfto.
  167. % Moved procedure ofsf_gsatlp to module cl.
  168. %
  169. % Revision 1.18 1996/02/28 13:15:24 sturm
  170. % Added quadratic special case detection to ofsf_varsel.
  171. % Fixed bugs in elimination set computation.
  172. %
  173. % Revision 1.17 1996/02/26 12:46:51 sturm
  174. % Started the implementation of a proper ofsf_varsel.
  175. % Added factorization to the ofsf_translat and ofsf_trygauss black box
  176. % implementations. Degree violations are communicated to the module cl
  177. % now.
  178. % Fixed a bug in ofsf_elimsetscl.
  179. % Removed treatment of ...2q keys from the elimination set computation.
  180. %
  181. % Revision 1.16 1996/02/18 15:55:14 sturm
  182. % Turned rlsiexpla on by default.
  183. %
  184. % Revision 1.15 1996/02/18 14:27:58 sturm
  185. % Updated export list.
  186. % Added factorization to ofsf_simplequal and ofsf_simplneq. Added
  187. % corresponding switch !*rlsifac.
  188. % Removed switch !*rlsdnf.
  189. % Added black box implementation ofsf_trygauss.
  190. % Changed default settings for the switches !*rlqedfs and !*rlsimpl.
  191. % Added service rlatl.
  192. % Added procedures ofsf_rotrel, ofsf_crotrel, and ofsf_reorder.
  193. % Moved ofsf_splitterm and ofsf_mksol from module ofsfqe to
  194. % ofsf_optsplitterm and ofsf_optmksol resp. in module ofsfopt.
  195. % Rewritten module ofsfqe. Implemented quadratic elimination. This module
  196. % is under development.
  197. %
  198. % Revision 1.14 1996/02/18 12:46:07 dolzmann
  199. % Added default value for switch !*rlgserf.
  200. % Rewritten module ofsfgs.
  201. %
  202. % Revision 1.13 1995/11/16 08:06:36 sturm
  203. % Added default setting for switch rlsimpl.
  204. %
  205. % Revision 1.12 1995/10/18 08:53:05 sturm
  206. % Added switches rlbnfsb, rlbnfsm, parameter rlsubsumption!*, and
  207. % respective code.
  208. % Bug fix: atomic formulas are made unique in ofsf_entry2at now.
  209. % Made ofsf_gsd use DNF computation.
  210. %
  211. % Revision 1.11 1995/09/05 08:05:15 sturm
  212. % Reimplemented parts of smart simplification. Added switches rlsipo,
  213. % rlsipw; fixed a bug in smart simplification of impl.
  214. % Modified procedure ofsf_esaord: improved substitution, added switch
  215. % rlqesdnf.
  216. %
  217. % Revision 1.10 1995/08/31 08:40:47 sturm
  218. % Added RTYPEFN property to all relations except equal.
  219. %
  220. % Revision 1.9 1995/08/30 08:09:15 sturm
  221. % Moved interface code to file rlsf and adapted the tag properties.
  222. % Fixed a bug: renamed cl_smsimpl!-equiv to ofsf_smsimpl!-equiv1.
  223. % Major changes in module ofsfopt:
  224. % Added BFS option to ofsf_opt2 using switch rlqedfs.
  225. % Changed return protocol in ofsf_opt2.
  226. % Added elimination set computation wrt. "z". Code contains some
  227. % experimental switches.
  228. % Added counting of tree nodes with verbose output.
  229. %
  230. % Revision 1.8 1995/08/08 10:18:18 sturm
  231. % Added smart simplification code for impl and equiv.
  232. % Adapted calls to cl_simpl to the new knowl argument.
  233. %
  234. % Revision 1.7 1995/08/03 05:39:06 dolzmann
  235. % Added procedures ofsf_gsn, ofsf_gsatlp.
  236. %
  237. % Revision 1.6 1995/08/02 08:19:08 sturm
  238. % Split module ofsfsimpl into ofsfsimplat and ofsfsmsimpl. Rewritten
  239. % smart simplification code.
  240. % Minor changes in module ofsfgs; fixed term ordering to REVGRADLEX.
  241. % Changed copyright messages.
  242. %
  243. % Revision 1.5 1995/07/12 15:08:54 sturm
  244. % Added procedure ofsf_optsubstat to module ofsfopt.
  245. % Added procedures ofsf_ordatp and ofsf_ordrelp.
  246. % Set service rl_identifyonoff to cl_identifyonoff.
  247. %
  248. % Revision 1.4 1995/07/07 11:12:25 sturm
  249. % Removed remflag statement for load!-package.
  250. % Removed "_" in switch names.
  251. % Added export statement.
  252. % Added switch rlopt1s.
  253. % Added procedures ofsf_qemkans (parameter function), ofsf_simpterm,
  254. % ofsf_prepterm, and ofsf_mkterm.
  255. % Added comments.
  256. % Changes in module ofsfopt.
  257. % Renamed Groebner simplifiers: ofsf_gbcsimpl to ofsf_gsc and
  258. % ofsf_gbdsimpl to ofsf_gsd.
  259. % Changed verbosity output, ioto is used now.
  260. %
  261. % Revision 1.3 1995/06/21 10:42:02 sturm
  262. % Removed declarations of non-used local variables.
  263. % Turned on switch rl_tabib by default.
  264. % Updated create!-package commented it out.
  265. % Many changes in module ofsfqe.
  266. % Added smart simplification code in module ofsfsimpl; ofsf_simpl1 is
  267. % used instead of of_simpl1 now.
  268. % Added module ofsfopt.
  269. %
  270. % Revision 1.2 1995/06/01 13:54:04 dolzmann
  271. % Added switch rl_verbose.
  272. % Fixed bugs in ofsf_simplleq and ofsf_simplgreaterp.
  273. % Added module ofsfgs containing a Groebner simplifier. Parts of the
  274. % interface have already been part of the previous revision.
  275. %
  276. % Revision 1.1 1995/05/29 14:47:21 sturm
  277. % Initial check-in.
  278. %
  279. % ----------------------------------------------------------------------
  280. lisp <<
  281. fluid '(ofsf_rcsid!* ofsf_copyright!*);
  282. ofsf_rcsid!* := "$Id: ofsf.red,v 1.24 1999/03/23 12:26:33 sturm Exp $";
  283. ofsf_copyright!* := "Copyright (c) 1995-1999 by A. Dolzmann and T. Sturm"
  284. >>;
  285. module ofsf;
  286. % Ordered field standard form. Main module. Algorithms on first-order
  287. % formulas over ordered fields. The language contains binary relations
  288. % ['equal], ['neq], ['greaterp], ['lessp], ['geq], ['leq].
  289. create!-package('(ofsf ofsfsiat ofsfsism ofsfbnf ofsfqe ofsfopt ofsfgs
  290. ofsfmisc),nil);
  291. load!-package 'cl;
  292. load!-package 'rltools;
  293. exports ofsf_simpterm,ofsf_prepat,ofsf_resimpat,ofsf_lengthat,ofsf_chsimpat,
  294. ofsf_simpat,ofsf_op,ofsf_arg2l,ofsf_arg2r,ofsf_argn,ofsf_mk2,ofsf_0mk2,
  295. ofsf_mkn,ofsf_opp,ofsf_mkstrict,ofsf_simplat1,ofsf_smrmknowl,ofsf_smcpknowl,
  296. ofsf_smupdknowl,ofsf_smmkatl,ofsf_dnf,ofsf_cnf,ofsf_subsumption,
  297. ofsf_sacatlp,ofsf_sacat,ofsf_varsel,ofsf_qesubcr1,ofsf_qesubcr2,ofsf_qesubr,
  298. ofsf_qesubcq,ofsf_qesubq,ofsf_qesubi,ofsf_qesubcrpe1,ofsf_qesubcrme1,
  299. ofsf_qesubcrpe2,ofsf_qesubcrme2,ofsf_qesubrpe,ofsf_qesubrme,ofsf_qesubcqpe,
  300. ofsf_qesubcqme,ofsf_qesubqpe,ofsf_qesubqme,ofsf_valassp,ofsf_translat,
  301. ofsf_surep,ofsf_elimset,ofsf_bettergaussp,ofsf_esetunion,ofsf_bestgaussp,
  302. ofsf_qefsolset,ofsf_qemkans,ofsf_preprexpr,ofsf_decdeg,ofsf_decdeg1,
  303. ofsf_transform,ofsf_updatr,ofsf_thsimpl,ofsf_specelim,ofsf_opt,ofsf_gsn,
  304. ofsf_gsc,ofsf_gsd,ofsf_gssimplify,ofsf_gssimplify0,ofsf_termprint,
  305. ofsf_canegrel,ofsf_anegrel,ofsf_clnegrel,ofsf_lnegrel,ofsf_fctrat,
  306. ofsf_negateat,ofsf_varlat,ofsf_varsubstat,ofsf_ordatp,ofsf_ordrelp,
  307. ofsf_a2cdl,ofsf_t2cdl,ofsf_subat,ofsf_subalchk,ofsf_eqnrhskernels,
  308. ofsf_getineq,ofsf_structat,ofsf_ifstructat,ofsf_termmlat,ofsf_multsurep;
  309. imports cl,rltools;
  310. fluid '(!*rlsiatadv !*rlsipd !*rlsiexpl !*rlsiexpla !*rlgssub !*rlsiso !*rlqesr
  311. !*rlgsrad !*rlgsred !*rlgsprod !*rlgserf !*rlverbose !*rlqedfs !*rlsipw
  312. !*rlsipo !*rlparallel !*rlopt1s !*rlsifac !*rlbnfsac !*rlgsvb !*rlqegen
  313. !*rlsitsqspl !*rlgsbnf !*rlgsutord !*rlqegenct !*rlqeheu !*rlnzden
  314. !*rlposden !*rladdcond !*rlqeqsc !*rlqesqsc !*rlsusi);
  315. flag('(ofsf),'rl_package);
  316. % Parameters
  317. put('ofsf,'rl_params,'(
  318. (rl_subat!* . ofsf_subat)
  319. (rl_subalchk!* . ofsf_subalchk)
  320. (rl_eqnrhskernels!* . ofsf_eqnrhskernels)
  321. (rl_ordatp!* . ofsf_ordatp)
  322. (rl_qemkans!* . ofsf_qemkans)
  323. (rl_simplat1!* . ofsf_simplat1)
  324. (rl_smupdknowl!* . ofsf_smupdknowl)
  325. (rl_smrmknowl!* . ofsf_smrmknowl)
  326. (rl_smcpknowl!* . ofsf_smcpknowl)
  327. (rl_smmkatl!* . ofsf_smmkatl)
  328. (rl_smsimpl!-impl!* . cl_smsimpl!-impl)
  329. (rl_smsimpl!-equiv1!* . cl_smsimpl!-equiv1)
  330. (rl_negateat!* . ofsf_negateat)
  331. (rl_varlat!* . ofsf_varlat)
  332. (rl_varsubstat!* . ofsf_varsubstat)
  333. (rl_translat!* . ofsf_translat)
  334. (rl_elimset!*. ofsf_elimset)
  335. (rl_trygauss!* . cl_trygauss)
  336. (rl_varsel!* . ofsf_varsel)
  337. (rl_subsumption!* . ofsf_subsumption)
  338. (rl_bnfsimpl!* . cl_bnfsimpl)
  339. (rl_sacat!* . ofsf_sacat)
  340. (rl_sacatlp!* . ofsf_sacatlp)
  341. (rl_fctrat!* . ofsf_fctrat)
  342. (rl_tordp!* . ordp)
  343. (rl_transform!* . ofsf_transform)
  344. (rl_updatr!* . ofsf_updatr)
  345. (rl_a2cdl!* . ofsf_a2cdl)
  346. (rl_t2cdl!* . ofsf_t2cdl)
  347. (rl_getineq!* . ofsf_getineq)
  348. (rl_qefsolset!* . ofsf_qefsolset)
  349. (rl_bettergaussp!* . ofsf_bettergaussp)
  350. (rl_bestgaussp!* . ofsf_bestgaussp)
  351. (rl_esetunion!* . ofsf_esetunion)
  352. (rl_structat!* . ofsf_structat)
  353. (rl_ifstructat!* . ofsf_ifstructat)
  354. (rl_termmlat!* . ofsf_termmlat)
  355. (rl_multsurep!* . ofsf_multsurep)
  356. (rl_specelim!* . ofsf_specelim)));
  357. % Services
  358. put('ofsf,'rl_services,'(
  359. (rl_subfof!* . cl_subfof)
  360. (rl_identifyonoff!* . cl_identifyonoff)
  361. (rl_simpl!* . cl_simpl)
  362. (rl_thsimpl!* . ofsf_thsimpl)
  363. (rl_nnf!* . cl_nnf)
  364. (rl_nnfnot!* . cl_nnfnot)
  365. (rl_pnf!* . cl_pnf)
  366. (rl_cnf!* . ofsf_cnf)
  367. (rl_dnf!* . ofsf_dnf)
  368. (rl_all!* . cl_all)
  369. (rl_ex!* . cl_ex)
  370. (rl_atnum!* . cl_atnum)
  371. (rl_tab!* . cl_tab)
  372. (rl_atab!* . cl_atab)
  373. (rl_itab!* . cl_itab)
  374. (rl_gsc!* . ofsf_gsc)
  375. (rl_gsd!* . ofsf_gsd)
  376. (rl_gsn!* . ofsf_gsn)
  377. (rl_qe!* . cl_qe)
  378. (rl_qea!* . cl_qea)
  379. (rl_gqe!* . cl_gqe)
  380. (rl_gqea!* . cl_gqea)
  381. (rl_qeipo!* . cl_qeipo)
  382. (rl_qews!* . cl_qews)
  383. (rl_opt!* . ofsf_opt)
  384. (rl_ifacl!* . cl_ifacl)
  385. (rl_ifacml!* . cl_ifacml)
  386. (rl_matrix!* . cl_matrix)
  387. (rl_apnf!* . cl_apnf)
  388. (rl_atml!* . cl_atml)
  389. (rl_tnf!* . cl_tnf)
  390. (rl_atl!* . cl_atl)
  391. (rl_struct!* . cl_struct)
  392. (rl_ifstruct!* . cl_ifstruct)
  393. (rl_termml!* . cl_termml)
  394. (rl_terml!* . cl_terml)
  395. (rl_varl!* . cl_varl)
  396. (rl_fvarl!* . cl_fvarl)
  397. (rl_bvarl!* . cl_bvarl)
  398. (rl_gentheo!* . cl_gentheo)
  399. (rl_decdeg!* . ofsf_decdeg)
  400. (rl_decdeg1!* . ofsf_decdeg1)
  401. (rl_surep!* . cl_surep)
  402. (rl_siaddatl!* . cl_siaddatl)));
  403. % Admin
  404. put('ofsf,'simpfnname,'ofsf_simpfn);
  405. put('ofsf,'simpdefault,'ofsf_simprel);
  406. put('ofsf,'rl_prepat,'ofsf_prepat);
  407. put('ofsf,'rl_resimpat,'ofsf_resimpat);
  408. put('ofsf,'rl_lengthat,'ofsf_lengthat);
  409. put('ofsf,'rl_prepterm,'prepf);
  410. put('ofsf,'rl_simpterm,'ofsf_simpterm);
  411. algebraic infix equal;
  412. put('equal,'ofsf_simpfn,'ofsf_chsimpat);
  413. put('equal,'number!-of!-args,2);
  414. algebraic infix neq;
  415. put('neq,'ofsf_simpfn,'ofsf_chsimpat);
  416. put('neq,'number!-of!-args,2);
  417. put('neq,'rtypefn,'quotelog);
  418. newtok '((!< !>) neq);
  419. algebraic infix leq;
  420. put('leq,'ofsf_simpfn,'ofsf_chsimpat);
  421. put('leq,'number!-of!-args,2);
  422. put('leq,'rtypefn,'quotelog);
  423. algebraic infix geq;
  424. put('geq,'ofsf_simpfn,'ofsf_chsimpat);
  425. put('geq,'number!-of!-args,2);
  426. put('geq,'rtypefn,'quotelog);
  427. algebraic infix lessp;
  428. put('lessp,'ofsf_simpfn,'ofsf_chsimpat);
  429. put('lessp,'number!-of!-args,2);
  430. put('lessp,'rtypefn,'quotelog);
  431. algebraic infix greaterp;
  432. put('greaterp,'ofsf_simpfn,'ofsf_chsimpat);
  433. put('greaterp,'number!-of!-args,2);
  434. put('greaterp,'rtypefn,'quotelog);
  435. flag('(equal neq leq geq lessp greaterp),'spaced);
  436. flag('(ofsf_chsimpat),'full);
  437. procedure ofsf_simpterm(u);
  438. numr simp u;
  439. procedure ofsf_prepat(f);
  440. {ofsf_op f,prepf ofsf_arg2l f,prepf ofsf_arg2r f};
  441. procedure ofsf_resimpat(f);
  442. ofsf_mk2(ofsf_op f,
  443. numr resimp !*f2q ofsf_arg2l f,numr resimp !*f2q ofsf_arg2r f);
  444. procedure ofsf_lengthat(f);
  445. 2;
  446. procedure ofsf_chsimpat(u);
  447. rl_smkn('and,for each x in ofsf_chsimpat1 u collect ofsf_simpat x);
  448. procedure ofsf_chsimpat1(u);
  449. begin scalar leftl,rightl,lhs,rhs;
  450. lhs := cadr u;
  451. if pairp lhs and ofsf_opp car lhs then <<
  452. leftl := ofsf_chsimpat1 lhs;
  453. lhs := caddr lastcar leftl
  454. >>;
  455. rhs := caddr u;
  456. if pairp rhs and ofsf_opp car rhs then <<
  457. rightl := ofsf_chsimpat1 rhs;
  458. rhs := cadr car rightl
  459. >>;
  460. return nconc(leftl,{car u,lhs,rhs} . rightl)
  461. end;
  462. procedure ofsf_simpat(u);
  463. % Ordered field simp atomic formula. [u] is Lisp prefix. Returns an
  464. % atomic formula.
  465. begin scalar op,lhs,rhs,nlhs,f;
  466. op := car u;
  467. lhs := simp cadr u;
  468. if not (!*rlnzden or !*rlposden or (domainp denr lhs)) then
  469. typerr(u,"atomic formula");
  470. rhs := simp caddr u;
  471. if not (!*rlnzden or !*rlposden or (domainp denr rhs)) then
  472. typerr(u,"atomic formula");
  473. lhs := subtrsq(lhs,rhs);
  474. nlhs := numr lhs;
  475. if !*rlposden and not domainp denr lhs then <<
  476. f := ofsf_0mk2(op,nlhs);
  477. if !*rladdcond then
  478. f := if op memq '(lessp leq greaterp geq) then
  479. rl_mkn('and,{ofsf_0mk2('greaterp,denr lhs),f})
  480. else
  481. rl_mkn('and,{ofsf_0mk2('neq,denr lhs),f});
  482. return f
  483. >>;
  484. if !*rlnzden and not domainp denr lhs then <<
  485. if op memq '(lessp leq greaterp geq) then
  486. nlhs := multf(nlhs,denr lhs);
  487. f := ofsf_0mk2(op,nlhs);
  488. if !*rladdcond then
  489. f := rl_mkn('and,{ofsf_0mk2('neq,denr lhs),f});
  490. return f
  491. >>;
  492. return ofsf_0mk2(op,nlhs)
  493. end;
  494. procedure ofsf_op(atf);
  495. % Ordered field operator. [atf] is an atomic formula
  496. % $R(t_1,t_2)$. Returns $R$.
  497. car atf;
  498. procedure ofsf_arg2l(atf);
  499. % Ordered field binary operator left hand side argument. [atf] is
  500. % an atomic formula $R(t_1,t_2)$. Returns $t_1$.
  501. cadr atf;
  502. procedure ofsf_arg2r(atf);
  503. % Ordered field binary operator right hand side argument. [atf] is
  504. % an atomic formula $R(t_1,t_2)$. Returns $t_2$.
  505. caddr atf;
  506. procedure ofsf_argn(atf);
  507. % Ordered field binary operator right hand side argument. [atf] is
  508. % an atomic formula $R(t_1,t_2)$. Returns the list $(t_1,t_2)$.
  509. {cadr atf,caddr atf};
  510. procedure ofsf_mk2(op,lhs,rhs);
  511. % Ordered field constructor for binary operator. [op] is a relation
  512. % [lhs] and [rhs] are terms. Returns the atomic formula
  513. % $[op]([lhs],[rhs])$.
  514. {op,lhs,rhs};
  515. procedure ofsf_0mk2(op,lhs);
  516. % Ordered field zero constructor for binary operator. [op] is a
  517. % relation [lhs] is a term. Returns the atomic formula
  518. % $[op]([lhs],0)$.
  519. {op,lhs,nil};
  520. procedure ofsf_mkn(op,argl);
  521. % Ordered field constructor for binary operator. [op] is a relation
  522. % [argl] is a list $(t_1,t_2)$ of terms. Returns the atomic formula
  523. % $[op](t_1,t_2)$.
  524. {op,car argl,cadr argl};
  525. procedure ofsf_opp(op);
  526. % Orderd field standard form operator predicate. [op] is an
  527. % S-expression. Returns [nil] if op is not a relation.
  528. op memq '(lessp leq equal neq geq greaterp);
  529. procedure ofsf_mkstrict(r);
  530. % Ordered field standard form make strict. [r] is an ordering
  531. % relation. Returns the strict part of [r].
  532. if r eq 'leq then 'lessp else if r eq 'geq then 'greaterp else r;
  533. endmodule; % [ofsf]
  534. end; % of file