ofsfgs.red 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569
  1. % ----------------------------------------------------------------------
  2. % $Id: ofsfgs.red,v 1.9 1999/03/23 07:41:37 dolzmann Exp $
  3. % ----------------------------------------------------------------------
  4. % Copyright (c) 1995-1999 Andreas Dolzmann and Thomas Sturm
  5. % ----------------------------------------------------------------------
  6. % $Log: ofsfgs.red,v $
  7. % Revision 1.9 1999/03/23 07:41:37 dolzmann
  8. % Changed copyright information.
  9. %
  10. % Revision 1.8 1997/08/24 16:16:59 sturm
  11. % Call cl_sitheo instead of ofsf_gssimpltheo.
  12. % Added service rl_surep with black box rl_multsurep.
  13. % Added service rl_siaddatl.
  14. %
  15. % Revision 1.7 1996/10/07 12:03:24 sturm
  16. % Added fluids for CVS and copyright information.
  17. %
  18. % Revision 1.6 1996/09/26 11:55:42 dolzmann
  19. % Reformated source code.
  20. %
  21. % Revision 1.5 1996/09/05 11:37:47 dolzmann
  22. % Removed unused variable vl in procedure ofsf_gsmkradvar.
  23. %
  24. % Revision 1.4 1996/09/05 11:14:57 dolzmann
  25. % Removed unused variable curtorder in procedure ofsf_gsmkradvar.
  26. %
  27. % Revision 1.3 1996/07/13 11:19:09 dolzmann
  28. % Introduced new switches !*rlgsbnf, !*rlgsutord and related code.
  29. %
  30. % Revision 1.2 1996/07/07 14:44:10 sturm
  31. % Call cl_nnfnot instead of cl_nnf1.
  32. %
  33. % Revision 1.1 1996/03/22 12:14:07 sturm
  34. % Moved and split.
  35. %
  36. % ----------------------------------------------------------------------
  37. lisp <<
  38. fluid '(ofsf_gs_rcsid!* ofsf_gs_copyright!*);
  39. ofsf_gs_rcsid!* := "$Id: ofsfgs.red,v 1.9 1999/03/23 07:41:37 dolzmann Exp $";
  40. ofsf_gs_copyright!* := "Copyright (c) 1995-1999 by A. Dolzmann and T. Sturm"
  41. >>;
  42. module ofsfgs;
  43. % Ordered field standard form groebner simplifier. Submodule of [ofsf].
  44. %DS
  45. % <cimpl> ::= (<gp>, <prod1>, <prod2>, <other>)
  46. % <gp> ::= ((<gb> . <prod>) . <other>)
  47. % <gb> ::= (<sf>,...)
  48. % <prod> ::= <sf>
  49. % <prod1> ::= <sf>
  50. % <prod2> ::= <sf>
  51. % <other> ::= (<atomic_formula>,...)
  52. procedure ofsf_gsc(f,atl);
  53. % Ordered field standard form groebner simplification via
  54. % conjunctive normal form. [f] is an formula; [atl] is a list of
  55. % atomic formulas, which are considered to describe a theory. An
  56. % formula equivalent to [f] is returned. The returned formula is
  57. % somehow simpler than [f]. This procedure sets the switch [groebopt]
  58. % temporary off. The parameters defined by [torder] are temporarily
  59. % overloaded by a [torder({},revgradlex)] statement.
  60. begin scalar w,svrlgsvb;
  61. svrlgsvb := !*rlgsvb;
  62. if !*rlverbose and !*rlgsvb then on1 'rlgsvb else off1 'rlgsvb;
  63. w := ofsf_gsc1(f,atl);
  64. onoff('rlgsvb,svrlgsvb);
  65. return w
  66. end;
  67. procedure ofsf_gsc1(f,atl);
  68. % Ordered field standard form groebner simplification via
  69. % conjunctive normal form. [f] is an formula; [atl] is a list of
  70. % atomic formulas, which are considered to describe a theory. An
  71. % formula equivalent to [f] or ['inctheo] is returned. The
  72. % returned formula is somehow simpler than [f].
  73. begin scalar phi,!*rlsiexpla; % Hack, but otherwise phi is not a bnf!
  74. if !*rlgsbnf then <<
  75. if !*rlgsvb then ioto_prin2 "[CNF";
  76. phi := cl_simpl(cl_cnf cl_nnf f,atl,-1);
  77. if !*rlgsvb then ioto_prin2 "] "
  78. >> else
  79. phi := cl_simpl(f,atl,-1);
  80. if phi eq 'inctheo then return 'inctheo;
  81. if rl_tvalp phi then
  82. return phi;
  83. phi := ofsf_gssimplify0(phi,atl);
  84. if phi eq 'inctheo then return 'inctheo;
  85. return cl_simpl(phi,atl,-1)
  86. end;
  87. procedure ofsf_gsd(f,atl);
  88. % Ordered field standard form groebner simplification via
  89. % disjunctive normal form. [f] is an formula; [atl] is a list of
  90. % atomic formulas, which are considered to describe a theory. An
  91. % formula equivalent to [f] or ['inctheo] is returned. The
  92. % returned formula is somehow simpler than [f]. This procedure sets
  93. % the switch [groebopt] temporary off. The parameters defined by
  94. % [torder] are temporary overloaded by a [torder({},revgradlex)]
  95. % statement.
  96. begin scalar w,svrlgsvb;
  97. svrlgsvb := !*rlgsvb;
  98. if !*rlverbose and !*rlgsvb then on1 'rlgsvb else off1 'rlgsvb;
  99. w := ofsf_gsd1(f,atl);
  100. onoff('rlgsvb,svrlgsvb);
  101. return w
  102. end;
  103. procedure ofsf_gsd1(f,atl);
  104. % Ordered field standard form groebner simplification via
  105. % disjunctive normal form. [f] is an formula; [atl] is a list of
  106. % atomic formulas, which are considered to describe a theory. An
  107. % formula equivalent to [f] or ['inctheo] is returned. The
  108. % returned formula is somehow simpler than [f].
  109. begin scalar phi,!*rlsiexpla; % Hack, but otherwise phi is not a bnf!
  110. if !*rlgsbnf then <<
  111. if !*rlgsvb then ioto_prin2 "[DNF";
  112. phi := cl_simpl(cl_nnfnot cl_dnf f,atl,-1);
  113. if !*rlgsvb then ioto_prin2 "] ";
  114. >> else
  115. phi := cl_simpl(cl_nnfnot f,atl,-1);
  116. if phi eq 'inctheo then return 'inctheo;
  117. if rl_tvalp phi then
  118. return cl_nnfnot phi;
  119. phi := ofsf_gssimplify0(phi,atl);
  120. if phi eq 'inctheo then return 'inctheo;
  121. return cl_simpl(cl_nnfnot phi,atl,-1)
  122. end;
  123. procedure ofsf_gsn(f,atl);
  124. % Ordered field standard form groebner simplification via boolean
  125. % normal form. [f] is an formula; [atl] is a list of atomic
  126. % formulas, which are considered to describe a theory. An
  127. % formula equivalent to [f] or ['inctheo] is returned. The
  128. % returned formula is somehow simpler than [f]. This procedure sets
  129. % the switch [!*groebopt] temporary off. The parameters defined by
  130. % [torder] are temporary overloaded by a [torder({},revgradlex)]
  131. % statement. This procedure calls in dependency of the structure of
  132. % [f] either [ofsf_gsc] or [ofsf_gsd]. The following heuristic is
  133. % used: Is [f] a conjunction of atomic formulas or a disjunction of
  134. % formulas with at least one complex formula then [ofsf_gsd] is
  135. % called; in other cases [ofsf_gsc] is called.
  136. if rl_tvalp f then
  137. f
  138. else if cl_atflp(rl_argn f) then
  139. if rl_op(f) eq 'and then ofsf_gsd(f,atl) else ofsf_gsc(f,atl)
  140. else
  141. if rl_op(f) eq 'and then ofsf_gsc(f,atl) else ofsf_gsd(f,atl);
  142. procedure ofsf_gssimplify0(f,atl);
  143. % Ordered field standard form groebner simplify. [f] is a
  144. % conjunction over disjunctions of atomic formulas or a
  145. % disjunctions of atomic formulas or an atomic formula; [atl] is a
  146. % list of atomic formulas, which are considered to describe a
  147. % theory. A formula is returned. This procedure binds temporarily
  148. % some global variables of the groebner packages.
  149. begin scalar res,oldtorder,!*groebopt,svkord;
  150. svkord := kord!*;
  151. oldtorder := cdr torder('((list) revgradlex));
  152. if !*rlgsutord then
  153. torder(oldtorder);
  154. res := ofsf_gssimplify(f,atl);
  155. torder oldtorder;
  156. kord!* := svkord;
  157. return res;
  158. end;
  159. procedure ofsf_gssimplify(f,atl);
  160. % Ordered field standard form groebner simplify. [f] is a
  161. % conjunction over disjunctions of atomic formulas or a
  162. % disjunctions of atomic formulas or an atomic formula; [atl] is a
  163. % list of atomic formulas, which are considered to describe a
  164. % theory. A formula is returned.
  165. begin scalar al,gp,ipart,npart,w,gprem,gprodal,gatl;
  166. atl := cl_sitheo atl;
  167. if atl eq 'inctheo or ofsf_gsinctheop(atl) then
  168. return 'inctheo;
  169. if (cl_atfp f) or (rl_op f eq 'or) then % degenerated cnf
  170. al := ofsf_gssplit!-cnf {f}
  171. else
  172. al := ofsf_gssplit!-cnf rl_argn f;
  173. if w := lto_catsoc('gprem,al) then <<
  174. gp := ofsf_gsextract!-gp atl;
  175. gprem := ofsf_gsgprem(w,gp);
  176. if gprem eq 'false then return 'false;
  177. >>;
  178. gatl := append(atl,lto_catsoc('gprem,al));
  179. gp := ofsf_gsextract!-gp(gatl);
  180. caar gp := sfto_groebnerf(caar gp);
  181. ipart := lto_catsoc('impl,al);
  182. npart := lto_catsoc('noneq,al);
  183. if ipart then
  184. ipart := ofsf_gspart(ipart,gp);
  185. if npart and gatl then
  186. npart := ofsf_gspart(npart,gp);
  187. if gprem then <<
  188. if null !*rlgsprod then <<
  189. gprodal := lto_catsoc('gprodal,al);
  190. gprem := ofsf_gssimulateprod(gprem,gprodal)
  191. >>;
  192. return rl_smkn('and,gprem . nconc(ipart,npart))
  193. >>;
  194. return rl_smkn('and,nconc(ipart,npart))
  195. end;
  196. procedure ofsf_gsinctheop(atl);
  197. % Ordered field standard form groebner simplifier inconsistent
  198. % theory predicate. [atl] is a list of atomic formulas.
  199. % [T] or [nil] is returned.
  200. begin scalar w;
  201. if null atl then
  202. return nil;
  203. if !*rlgsvb then ioto_prin2 "Inctheop... ";
  204. w := cl_nnfnot ofsf_gsimplication(
  205. cl_nnfnot rl_smkn('and,atl),'((nil . 1) . nil));
  206. if !*rlgsvb then ioto_prin2t "done.";
  207. return w eq 'false
  208. end;
  209. procedure ofsf_gssplit!-cnf(f);
  210. % Ordered field standard form groebner simplifier split conjunctive
  211. % normal form. [f] is an list of disjunctions of atomic formulas.
  212. % An assoc list is returned. The returned assoc list have the
  213. % following items. [('impl . imp)] where [imp] is the list off all
  214. % disjunctions containing at least one inequation, [('gprem .
  215. % gprem)] where [gprem] is the list of all atomic formulas occuring
  216. % in [f] and atomic formulas equivalent to disjunctions of
  217. % inequalities occuring in [f], [('noneq . noneq)] where [noneq] is
  218. % a list of disjunctions of atomic formulas containing no
  219. % inequations, and [('gprodal . gprodal)]. The value [gprodal] is a
  220. % assoc list containing to each equation the product
  221. % representation, if the equation was extracted from a disjunction.
  222. begin scalar noneq,imp,prod,gprodal,gprem,w,x;
  223. for each phi in f do
  224. if rl_op phi memq '(and or) then % [phi] is not an atomic formula
  225. if (w := ofsf_gsdis!-type rl_argn phi) eq 'impl then
  226. imp := phi . imp
  227. else if w eq 'noneq then
  228. noneq := phi . noneq
  229. else << % [if w eq 'equal then]
  230. prod := 1;
  231. for each atf in rl_argn phi do
  232. prod := multf(prod,ofsf_arg2l atf);
  233. x := ofsf_0mk2('equal,prod);
  234. gprem := x . gprem;
  235. gprodal := (x . phi) . gprodal
  236. >>
  237. else
  238. gprem := phi . gprem;
  239. if !*rlgsvb then <<
  240. ioto_tprin2t {"global: ",length gprem,"; impl: ",length imp,
  241. "; no neq: ",length noneq, "; glob-prod-al: ",length gprodal,"."}
  242. >>;
  243. return { 'impl . imp, 'noneq . noneq, 'gprem . gprem, 'gprodal . gprodal}
  244. end;
  245. procedure ofsf_gsdis!-type(atl);
  246. % Ordered field standard form groebner simplifier disjunction type.
  247. % [atl] is a non null list of atomic formulas. ['equal],
  248. % ['impl], or ['noneq] is returned. ['equal] is returned if and
  249. % only if all atomic formulas have the relation [equal]; [impl] is
  250. % returned, if and only if one of the atomic formula is an
  251. % equality, otherwise [noneq] is returned.
  252. begin scalar op,w;
  253. if null atl then return 'equal;
  254. op := ofsf_op car atl;
  255. if op eq 'neq then return 'impl;
  256. w := ofsf_gsdis!-type cdr atl;
  257. if w eq 'impl then return 'impl;
  258. if op eq 'equal and w eq 'equal then return 'equal;
  259. return 'noneq
  260. end;
  261. procedure ofsf_gsextract!-gp(atl);
  262. % Ordered field standard form extract global premise. [atl] is a
  263. % list of atomic formulas. A GP is returned.
  264. begin scalar w;
  265. w := ofsf_gsdis2impl(for each at in atl collect ofsf_negateat(at));
  266. return ( (car w . multf(cadr w, caddr w)) . cadddr w)
  267. end;
  268. procedure ofsf_gsgprem(atl,gp);
  269. % Ordered field standard form groebner simplifier simplify global
  270. % premise. [atl] is a list of atomic formulas; [gp] is a GP. A
  271. % formula is returned.
  272. begin scalar w;
  273. if !*rlgsvb then ioto_prin2 "[GP";
  274. w := cl_nnfnot ofsf_gsimplication(cl_nnfnot rl_smkn('and,atl),gp);
  275. if !*rlgsvb then ioto_prin2 "] ";
  276. return w
  277. end;
  278. procedure ofsf_gspart(part,gp);
  279. % Ordered field standard form groebner simplify simplify part.
  280. % [part] is a list of disjunctions of atomic formulas and atomic
  281. % formulas. [gp] is a GP. A list [l] of disjunctions of
  282. % atomic formulas and atomic formulas is returned. The formula on
  283. % position $i$ in [l] is somehow simpler than the formula on the
  284. % position $i$ in part. Supposed that the formula
  285. % $\bigwedge(g_i=0)$ is true where $g_i$ are the terms in [gp] then
  286. % the positional corresponding fomulas in the two lists [part] and
  287. % [l] are equivalent.
  288. begin scalar w,curlen,res;
  289. if !*rlgsvb then curlen := length part;
  290. res := for each phi in part collect <<
  291. if !*rlgsvb then ioto_prin2 {"[",curlen};
  292. w := ofsf_gsimplication(phi,gp);
  293. if !*rlgsvb then << curlen := curlen - 1; ioto_prin2 {"] "} >>;
  294. w
  295. >>;
  296. if !*rlgsvb then ioto_cterpri();
  297. return res
  298. end;
  299. procedure ofsf_gsimplication(f,gp);
  300. % Ordered field standard form groebner simplification implication.
  301. % [f] is a disjunction of atomic formulas or an atomic formula.
  302. % [gp] is a GP. Returns a formula. It is a truth
  303. % value, an atomic formula or a disjunction of atomic formulas,
  304. % unless the simplification of an atomic formula yields a complex
  305. % formula.
  306. begin scalar prem,prod1,prod2,gprod,rprod,iprem,w,z,atl,natl;
  307. if cl_cxfp f then atl := rl_argn f else atl := {f};
  308. w := ofsf_gsdis2impl atl;
  309. iprem := car w;
  310. prod1 := cadr w;
  311. prod2 := caddr w;
  312. gprod := cdar gp;
  313. prem := append(iprem,caar gp);
  314. if null prem then return f;
  315. prem := sfto_groebnerf prem;
  316. z := numr simp ofsf_gsmkradvar();
  317. rprod := ofsf_gseqprod(prod1,prod2,gprod,prem,z);
  318. if rprod eq 'true then <<
  319. if !*rlgsvb then ioto_prin2 "!";
  320. return 'true
  321. >>;
  322. w := ofsf_gsusepremise(cdr gp,prem,z);
  323. if w eq 'true then <<
  324. if !*rlgsvb then ioto_prin2 "!";
  325. return 'true
  326. >>;
  327. natl := ofsf_gsredatl(atl,prem,z,rprod);
  328. if natl eq 'true then <<
  329. if !*rlgsvb then ioto_prin2 "!";
  330. return 'true
  331. >>;
  332. if rprod and rprod neq 'false then natl := rprod . natl;
  333. natl := nconc(natl,ofsf_gspremise(iprem,caar gp));
  334. return rl_smkn('or,natl)
  335. end;
  336. procedure ofsf_gsredatl(atl,prem,z,rprod);
  337. % Ordered field standard form reduce atomic formula list. [atl] is
  338. % a list of SF's; [prem] is a groebner basis; [z] is a kernel;
  339. % [rprod] is a flag. Returns ['true] or a list of atomic formulas.
  340. begin scalar a,w,natl;
  341. while atl do <<
  342. a := car atl;
  343. atl := cdr atl;
  344. w := ofsf_gsredat(a,prem,z,rprod);
  345. if w eq 'true then
  346. atl := nil
  347. else if w and w neq 'false then
  348. natl := w . natl
  349. >>;
  350. if w eq 'true then return 'true;
  351. return natl;
  352. end;
  353. procedure ofsf_gsusepremise(atl,prem,z);
  354. % Ordered field standard form use premise. [atl] is a list of
  355. % atomic formulas; [prem] is a groebner basis; [z] is a kernel.
  356. % returns [nil] or ['true].
  357. begin scalar w;
  358. while atl do <<
  359. w := ofsf_gsredat(car atl,prem,z,nil);
  360. if w eq 'true then
  361. atl := nil
  362. else
  363. atl := cdr atl;
  364. >>;
  365. if w eq 'true then return 'true;
  366. end;
  367. procedure ofsf_gseqprod(iprod1,iprod2,gprod,prem,z);
  368. % Ordered field standard form equation product. [iprod1], [iprod2],
  369. % and [prem] are SF's; [prem] is a list of SF's; [z] is a kernel.
  370. % Returns [nil] or a formula.
  371. begin scalar p,w;
  372. p := multf(iprod1,multf(iprod2,gprod));
  373. % Comment the test on [!*rlgsrad] out if the radical membership
  374. % test should always be performed for the equation product.
  375. if !*rlgsrad and
  376. (null sfto_greducef(1,addf(1,negf multf(p,z)) . prem))
  377. then
  378. return 'true;
  379. w := ofsf_gstryeval('equal,sfto_preducef(p,prem));
  380. if rl_tvalp w then return w;
  381. if null !*rlgsprod then return nil;
  382. if !*rlgsred then
  383. return ofsf_0mk2('equal,sfto_preducef(iprod1,prem));
  384. return ofsf_0mk2('equal,iprod1);
  385. end;
  386. procedure ofsf_gsmkradvar();
  387. % Ordered field standard form groebner simplifier make radical
  388. % memebership test variable. Returns an identifier that is not used
  389. % as an algebraic mode variable.
  390. begin scalar w; integer n;
  391. w := 'rlgsradmemv!*;
  392. while get(w,'avalue) do
  393. w := mkid(w,n := n+1);
  394. if !*rlgsutord then
  395. ofsf_gsupdtorder w;
  396. return w;
  397. end;
  398. procedure ofsf_gsupdtorder(v);
  399. % Ordered field standard form groebner simplifier update term
  400. % order. [v] is a kernel. Inserts the main variable [v] into the
  401. % variable list of the global fixed term order of the groebner
  402. % package. Not all torders are supported, if a variable list is
  403. % present. To get over this problem one can insert the tag
  404. % variable [v] in the variable list before calling the groebner
  405. % simplifier.
  406. begin scalar curtorder,vl,remain,mode;
  407. curtorder := cdr torder('((list) revgradlex));
  408. vl := cdar curtorder;
  409. if null vl or (v memq vl) then <<
  410. torder curtorder;
  411. return nil
  412. >>;
  413. mode := cadr curtorder;
  414. if not(mode memq '(lex gradlex revgradlex gradlexgradlex
  415. gradlexrevgradlex lexgradlex lexrevgradlex weighted))
  416. then
  417. rederr {"term order", mode, "not supported"};
  418. remain := cddr curtorder;
  419. vl := append(vl,{v});
  420. torder (('list . vl) . mode . remain);
  421. end;
  422. procedure ofsf_gstryeval(rel,lhs);
  423. % Ordered field standard form try evaluation. [rel] is an
  424. % ofsf-relation; [lhs] a SF. returns [nil], a truth value or an
  425. % atomic formula. In the first case the atomic formula $([lhs]
  426. % [rel] 0)$ cannot be evaluated or should be ignored. In the other
  427. % case the returned value is equivalent to the the atomic formula.
  428. begin scalar w,!*rlsiexpla;
  429. if !*rlgserf then <<
  430. w := cl_simplat(ofsf_0mk2(rel,lhs),nil);
  431. return if rl_tvalp w then w;
  432. >>;
  433. if domainp lhs then
  434. return cl_simplat(ofsf_0mk2(rel,lhs),nil);
  435. end;
  436. procedure ofsf_gsdis2impl(atl);
  437. % Ordered field standard form groebner simplifier disjunction to
  438. % implication. [atl] is a list of atomic formulas. A CIMPL is
  439. % returned. The classification of the atomic formulas in [atl] is
  440. % done by [ofsf_attype].
  441. begin scalar prem,prod1,prod2,other,w,a;
  442. prod1 := prod2 := 1;
  443. for each at in atl do <<
  444. w := ofsf_gsattype at;
  445. if w then <<
  446. a := car w;
  447. if a eq 'equal then
  448. prod1 := multf(cdr w,prod1)
  449. else if a eq 'cequal then
  450. prod2 := multf(cdr w,prod2)
  451. else if a eq 'neq then
  452. prem := cdr w . prem
  453. else
  454. rederr {"BUG IN OFSF_GSDIS2IMPL",car w}
  455. >>;
  456. if not (w memq '(equal neq)) then
  457. other := at . other
  458. >>;
  459. return {prem, prod1, prod2, other};
  460. end;
  461. procedure ofsf_gsattype(at);
  462. % Ordered field standard form groebner simplifier atomic formula
  463. % type. [at] is an atomic formula. [nil] or a pair $(\rho,p)$ is
  464. % returned. $\rho$ is either ['equal], ['neq], or ['cequal]; $p$ is
  465. % a SF.
  466. (if w eq 'equal then
  467. ('equal . ofsf_arg2l at)
  468. else if w memq '(geq leq) then
  469. ('cequal . ofsf_arg2l at)
  470. else if w eq 'neq then
  471. ('neq . ofsf_arg2l at)) where w=ofsf_op at;
  472. procedure ofsf_gsredat(at,gb,z,flag);
  473. % Ordered field standard form groebner simplifier reduce atomic
  474. % formula. [at] is an atomic formula; [gb] is a Groebner basis; [z]
  475. % is a variable; [flag] is a flag. [nil], a truth value or an
  476. % atomic formula is returned. The behavior of this procedure
  477. % depends on the switches [rl_gsred] and [rl_gsrad]. [nil] is
  478. % returned if the atomic formula belongs to the premise or [flag]
  479. % is [T] and [at] is an equation. Is [flag] is non [nil] then
  480. % equations can be ignored. In the other cases the returned value
  481. % is equivalent to [at]. The intention of this procedure is the
  482. % reduction of [at] wrt. the radical generated by [gb].
  483. begin scalar w,x,op,arg,nat;
  484. op := ofsf_op at;
  485. if (op eq 'neq) or (flag and op eq 'equal) then return nil;
  486. arg := ofsf_arg2l at;
  487. w := sfto_preducef(arg,gb);
  488. if !*rlgsred then
  489. nat := cl_simplat(ofsf_0mk2(op,w),nil)
  490. else
  491. if x := ofsf_gstryeval(op,w) then
  492. nat := x
  493. else
  494. nat := at;
  495. if (rl_tvalp nat) or (op eq 'equal) or (null !*rlgsrad) then
  496. return nat;
  497. if null sfto_greducef(1,addf(1,negf multf(w,z)) . gb) then
  498. return cl_simplat(ofsf_0mk2(op,nil),nil);
  499. return nat;
  500. end;
  501. procedure ofsf_gspremise(tl,gp);
  502. % Ordered field standard form groebner simplify premise. [tl] and
  503. % [gp] are lists of SF's. A list of atomic formulas is returned.
  504. % The behavior of this procedure depends on the switches [rl_gsred]
  505. % and [rl_gssub]. The conjunction over the returned formulas is
  506. % equivalent to the formula $\bigvee(t_i \neq 0)$ supposed that
  507. % $\bigwedge(g_j = 0)$, where $t_i$ are the terms in [tl] and $g_j$
  508. % are the terms in [gp]. If the switch [rl_gsred] is on then all
  509. % terms $t_i$ are reduced modulo Id([gp]). If the switch [!*rl_gssub]
  510. % is on, the term list is substituted by the reduced groebner base
  511. % of the term list.
  512. begin scalar gb,rtl,w;
  513. if !*rlgsred then <<
  514. gb := sfto_groebnerf gp;
  515. for each sf in tl do
  516. if w := sfto_preducef(sf,gb) then
  517. rtl := lto_insert(w,rtl);
  518. >> else
  519. rtl := tl;
  520. if !*rlgssub then
  521. return for each sf in sfto_groebnerf rtl collect
  522. ofsf_0mk2('neq,sf);
  523. return for each sf in rtl collect
  524. ofsf_0mk2('neq,sf)
  525. end;
  526. procedure ofsf_gssimulateprod(prem,prodal);
  527. % Ordered field standard form simulate rlprod switch. [prem] is a
  528. % quantifier free formula. [prodal] is an assoc list containing to
  529. % some equations its product representation. truth value or an
  530. begin scalar w,res;
  531. if rl_tvalp prem then return prem;
  532. if cl_atfp prem and (w := lto_cassoc(prem,prodal)) then
  533. return w;
  534. res := for each f in rl_argn prem collect
  535. if cl_atfp f and (w := lto_cassoc(f,prodal)) then w else f;
  536. return rl_mkn(rl_op prem,res)
  537. end;
  538. endmodule; % [ofsfgs]
  539. end; % of file