pasfsism.red 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769
  1. % ----------------------------------------------------------------------
  2. % $Id: pasfsism.red,v 1.11 2004/02/22 21:08:15 lasaruk Exp $
  3. % ----------------------------------------------------------------------
  4. % Copyright (c) 2003 Andreas Dolzmann and Andreas Seidl
  5. % ----------------------------------------------------------------------
  6. % $Log: pasfsism.red,v $
  7. % Revision 1.11 2004/02/22 21:08:15 lasaruk
  8. % Added switch rlsusisubst for substitution of equalities. Substitution
  9. % results in smaller formulas or formulas with less free variables.
  10. % Up to 80% length reduction. Switch rlsusitr should not be used yet.
  11. %
  12. % Revision 1.10 2003/12/16 10:19:58 dolzmann
  13. % Removed wrong return values of pasf_susibinad. Added code for
  14. % substituting equations into atomic formulas occuring in the theory.
  15. %
  16. % Revision 1.9 2003/12/16 07:45:34 lasaruk
  17. % Redlog normal form in the simplifier.
  18. %
  19. % Revision 1.8 2003/12/11 10:51:19 lasaruk
  20. % Smart simplification improoved.
  21. %
  22. % Revision 1.7 2003/12/02 09:04:06 dolzmann
  23. % Removed parser error.
  24. %
  25. % Revision 1.6 2003/12/02 07:43:08 lasaruk
  26. % Additive smart simplification added.
  27. %
  28. % Revision 1.5 2003/11/28 09:36:54 sturm
  29. % Fixes in pasf_susibineq: do nothing for congrunces with different moduli.
  30. % Exchanged T with nil at two points.
  31. %
  32. % Revision 1.4 2003/11/28 09:11:11 dolzmann
  33. % Inserted a linebreak after rcsid!*.
  34. %
  35. % Revision 1.3 2003/11/27 19:30:40 lasaruk
  36. % Smart simplification added
  37. %
  38. % Revision 1.2 2003/11/05 13:27:14 lasaruk
  39. % Some major redlog programming rules applied to the code.
  40. % Formulas are made positive acc. to the current kernel order.
  41. %
  42. % Revision 1.1 2003/07/22 12:42:59 seidl
  43. % Smart simplification with theory based on susi started.
  44. %
  45. % ----------------------------------------------------------------------
  46. lisp <<
  47. fluid '(pasf_sism_rcsid!* pasf_sism_copyright!*);
  48. pasf_sism_rcsid!* :=
  49. "$Id: pasfsism.red,v 1.11 2004/02/22 21:08:15 lasaruk Exp $";
  50. pasf_sism_copyright!* :=
  51. "Copyright (c) 2003 by A. Dolzmann. A. Seidl and T. Sturm"
  52. >>;
  53. module pasfsism;
  54. % PASF smart simplification. Submodule of [pasf].
  55. procedure pasf_smwupdknowl(op,atl,knowl,n);
  56. % Presburger arithmetic standard form update knowledge. [op] is an
  57. % operator; [atl] is the list of atomic formulas to add to the
  58. % knowledge; [knowl] is a knowledge; [n] is the level. Returns
  59. % modified knowledge.
  60. if !*rlsusi then
  61. cl_susiupdknowl(op,atl,knowl,n)
  62. else
  63. cl_smupdknowl(op,atl,knowl,n);
  64. procedure pasf_smwrmknowl(knowl,v);
  65. % Presburger arithmetic standard form remove variable from the
  66. % knowledge. [knowl] is a knowledge; [v] is the variable to
  67. % remove. Returns modified knowledge.
  68. if !*rlsusi then
  69. pasf_susirmknowl(knowl,v)
  70. else
  71. cl_smrmknowl(knowl,v);
  72. procedure pasf_smwcpknowl(knowl);
  73. % Presburger arithmetic standard form copy knowledge. [knowl] is a
  74. % knowledge. Returns a copy of the knowledge.
  75. if !*rlsusi then
  76. cl_susicpknowl(knowl)
  77. else
  78. cl_smcpknowl(knowl);
  79. procedure pasf_smwmkatl(op,knowl,newknowl,n);
  80. % Presburger arithmetic standard form ...?
  81. if !*rlsusi then
  82. cl_susimkatl(op,knowl,newknowl,n)
  83. else
  84. cl_smmkatl(op,knowl,newknowl,n);
  85. procedure pasf_susirmknowl(knowl,v);
  86. % Presburger arithmetic standard form remove knowledge. [knowl] is
  87. % a KNOWL; [v] is a variable. Returns a KNOWL. Remove all
  88. % information about [v] from [knowl].
  89. for each p in knowl join
  90. if v memq pasf_varlat car p then nil else {p};
  91. procedure pasf_susibin(old,new);
  92. % Presburger arithmetic standard form susi binary smart
  93. % simplification. [old] and [new] are LAT's. Returns ['false] or a
  94. % SUSIPRG. We assume that [old] is a part of a already existence
  95. % KNOWL and new has to be added to this KNOWL.
  96. begin scalar x,rm;
  97. % Do not make conclusion simplification
  98. if cdr old eq 'ignore and cdr new eq 'ignore then
  99. return nil;
  100. x := pasf_susibinad(old,new);
  101. % print "-----------------------";
  102. % mathprint rl_mk!*fof car old;
  103. % print cdr old;
  104. % mathprint rl_mk!*fof car new;
  105. % print cdr old;
  106. % print "sisibin->ouput";
  107. % print x;
  108. if x and listp x and
  109. (cdr new eq 'ignore or cdr old eq 'ignore) and
  110. not cdr x and caar x eq 'delete then <<
  111. print x;
  112. % Abort replacing theory with conclusions
  113. return nil
  114. >>
  115. else
  116. return x
  117. end;
  118. procedure pasf_susibinad(old,new);
  119. % Presburger standard form additive smart simplification. [old] is
  120. % the old atomic formula in the theory; [new] is the new atomic
  121. % formula found. Returns a susiprog that simplifies the formula.
  122. begin scalar od,nd,level,atf,olevel,res;
  123. level := cl_susiminlevel(cdr old,cdr new);
  124. olevel := cdr old;
  125. old := car old;
  126. new := car new;
  127. % Check for possible substitution
  128. if !*rlsusisubst and
  129. (pasf_opn old eq 'equal or pasf_opn new eq 'equal) then <<
  130. res := pasf_susibinsubst(old,new,level);
  131. if res then
  132. return res
  133. >>;
  134. % Equal lefthand sides simplification
  135. if pasf_arg2l old = pasf_arg2l new then
  136. return pasf_susibineq(pasf_arg2l old,pasf_op old,pasf_op new,level);
  137. % Decomposing both atomic formulas for additive simplification
  138. od := pasf_susidec(pasf_arg2l old);
  139. nd := pasf_susidec(pasf_arg2l new);
  140. if car od = car nd then
  141. % Equal parametric parts
  142. return pasf_susibinord(pasf_op old,pasf_arg2l old,cdr od,
  143. pasf_op new,pasf_arg2l new,cdr nd,level);
  144. % Transitive simplification
  145. if !*rlsusitr then
  146. return pasf_susibintr(old,new,level)
  147. else
  148. return nil;
  149. end;
  150. procedure pasf_atf2susiprog(atf,level,act);
  151. % Presburger arithmetic standard form atomic formula to susiprog
  152. % conversion. [atf] is an atomic formula; [level] is the level of
  153. % [atf] in the formula; [act] is the action to do with old or new
  154. % formula. Returns $'false$ if [atf] is a contradiction, {(delete
  155. % . T)} if [atf] is a tautology and {'(delete . [act]),('add . (atf
  156. % . level)} else.
  157. if atf eq 'true then
  158. % New formula is always true under theory conditions
  159. {('delete . act)}
  160. else if atf eq 'false then
  161. % Contradiction
  162. 'false
  163. else
  164. {('delete . act),('add . (atf . level))};
  165. procedure pasf_susibinsubst(old,new,level);
  166. % Presburger arithmetic standard form smart substitution
  167. % simplification. [old] and [new] are atomic formulas; [level] is
  168. % the recursion level. Returns a susiprog.
  169. begin scalar res,subst,into,atf,flag;
  170. % Determining what formula is substituted
  171. if pasf_opn old eq 'equal and pasf_opn new eq 'equal then
  172. % If both atomic formulas are equalities the result atomic formula
  173. % should contain less free variables as the input formula with the
  174. % biggest amount of free variables to avoid cyclic
  175. % substitutions. Substituted is the formula with smallest amount of
  176. % free variables.
  177. if length rl_fvarl old < length rl_fvarl new then <<
  178. % Substituting old into the new
  179. subst := old;
  180. into := new;
  181. flag := T
  182. >> else <<
  183. % Substituting new into the old
  184. subst := new;
  185. into := old;
  186. flag := nil
  187. >>
  188. else if pasf_opn old eq 'equal then <<
  189. % Substituting old into the new
  190. subst := old;
  191. into := new;
  192. flag := T
  193. >> else <<
  194. % Substituting new into the old
  195. subst := new;
  196. into := old;
  197. flag := nil
  198. >>;
  199. % Testing the substitution condition
  200. atf := pasf_simplat1 pasf_0mk2(pasf_op into,
  201. addf(pasf_arg2l into,negf pasf_arg2l subst));
  202. if length rl_fvarl atf < length rl_fvarl into and not rl_tvalp atf then
  203. return {('delete . flag), ('add . (atf . level))};
  204. atf := pasf_simplat1 pasf_0mk2(pasf_op into,
  205. addf(pasf_arg2l into,pasf_arg2l subst));
  206. if length rl_fvarl atf < length rl_fvarl into and not rl_tvalp atf then
  207. return {('delete . flag), ('add . (atf . level))};
  208. % Nothing could be done
  209. return nil;
  210. end;
  211. procedure pasf_susibintr(old,new,level);
  212. % Presburger arithmetic standard form smart transitive
  213. % simplification. [old] and [new] are atomic formulas; [level] is
  214. % the recursion level. Returns a susiprog.
  215. begin scalar res,sw;
  216. % First testing if simplification works in the order new into old
  217. res := pasf_susibintr1(old,new,level);
  218. if not res then <<
  219. % Simplification in the order old into new
  220. res := pasf_susibintr1(new,old,level);
  221. sw := 't;
  222. >>;
  223. if res eq 'false then
  224. return res;
  225. return res;
  226. end;
  227. procedure pasf_susibintr1(old,new,level);
  228. % Presburger arithmetic standard form smart transitive
  229. % simplification subprocedure. [old] and [new] are atomic formulas;
  230. % [level] is the recursion level. Returns a susiprog.
  231. begin scalar atf,rel,cold,aw;
  232. rel := pasf_smtrtable(pasf_opn old,pasf_opn new);
  233. % No simplification in this direction is possible
  234. if not rel then
  235. return nil;
  236. atf := pasf_simplat1
  237. pasf_0mk2(rel,addf(pasf_arg2l old,negf pasf_arg2l new));
  238. % Amount of free variables in both atomic formulas
  239. cold := length rl_fvarl pasf_mkn('and,{old,new});
  240. % Amount of free variables that are eliminated
  241. aw := cold - length rl_fvarl atf;
  242. % Only simplify if the amount of free variables goes down
  243. if aw > 0 then <<
  244. % Transitive simplification turns out to be an equivalence
  245. % operation if the substituted atomic formula is an equality.
  246. if pasf_opn old eq 'equal or pasf_opn new eq 'equal then <<
  247. % Under this assumptions a real contradiction is found
  248. if atf eq 'false then
  249. return 'false;
  250. if atf eq 'true then
  251. rederr {"True in transitive simplification shound not occur"};
  252. return {('add . (atf . level))}
  253. >>;
  254. % Drawing an implicative conclusion
  255. return {('add . (atf . 'ignore))}
  256. >>;
  257. return nil
  258. end;
  259. procedure pasf_susibineq(u,oop,nop,level);
  260. % Presburger arithmetic standard form smart simplification be equal
  261. % lefthand terms. [u] is the (common) lefthand term; [oop] is the
  262. % old operator in the theory; [nop] is the new operator in the
  263. % found atomic formula; [level] is the recursion level of the new
  264. % found atomic formula. Returns a susiprog that simplifies the
  265. % formula.
  266. begin scalar w;
  267. % Congruences with different moduli
  268. if pairp oop and pairp nop and cdr oop neq cdr nop then
  269. return pasf_susibineqcong(u,oop,nop,level);
  270. % ASSUMPTION: A congruence is never in the output of pasf_smeqtable
  271. w := pasf_smeqtable(
  272. if pairp oop then car oop else oop,
  273. if pairp nop then car nop else nop);
  274. if car w eq nil then
  275. % Nothing can be done
  276. return nil
  277. else if car w eq 'false then
  278. % Contradiction found
  279. return 'false
  280. else if car w eq 1 then
  281. % Remove new atomic formula from the level
  282. return {'(delete . T)}
  283. else if car w eq 2 then
  284. % Remove old atomic formula from the theory, add new atomic
  285. % formula to the knowledge
  286. return {'(delete . nil)}
  287. else if car w eq 3 then
  288. % Remove old atomic formula from the theory, remove new
  289. % atomic formula from the level, add modified atomic formula to
  290. % the level
  291. return {'(delete . nil), '(delete . T),
  292. ('add . (pasf_0mk2(cdr w, u) . level))}
  293. else if car w eq 4 then
  294. % Remove new atomic formula from the level, add modified
  295. % atomic formula to the level
  296. return {'(delete . T),
  297. ('add . (pasf_0mk2(cdr w, u) . level))}
  298. else
  299. % Remove old atomic formula from the theory, add modified
  300. % atomic formula to the level
  301. return {'(delete . nil),
  302. ('add . (pasf_0mk2(cdr w, u) . level))};
  303. end;
  304. procedure pasf_susidec(u);
  305. % Presburger arithmetic standard form decompose atomic
  306. % fqormula. [u] is a SF. Returns a pair $(p . a)$, where $p$ and
  307. % $a$ are SF's. $p$ is the parametric part of [u] and
  308. % $a$ is the absolut part of [u].
  309. begin scalar par,absv,c;
  310. absv := u;
  311. while not domainp absv do
  312. absv := red absv;
  313. return (addf(u,negf absv) . absv)
  314. end;
  315. procedure pasf_susibineqcong(u,oop,nop,level);
  316. % Presburger arithmetic standard form smart equal simplification
  317. % with equal lefthand terms in congruences with different
  318. % moduli. [u] is the (common) lefthand term; [oop] is the old
  319. % operator in the theory; [nop] is the new operator in the found
  320. % atomic formula; [level] is the recursion level of the new found
  321. % atomic formula. Returns a susiprog that simplifies the formula.
  322. begin
  323. scalar n,m;
  324. n := cdr oop;
  325. m := cdr nop;
  326. % Both formulas are congruences
  327. if car oop eq 'cong and car nop eq 'cong then
  328. return{'(delete . nil),'(delete . T),
  329. ('add . (pasf_0mk2(pasf_mkop('cong,lcm(m,n)),u) . level))};
  330. % Old formula is a congruence and new is a incongruence
  331. if car oop eq 'cong and car nop eq 'ncong then
  332. if remainder(n,m) = 0 then
  333. return 'false
  334. else
  335. return nil;
  336. % Old formula is an incongruence and new is a congurence
  337. if car oop eq 'ncong and car nop eq 'cong then
  338. if remainder(m,n) = 0 then
  339. return 'false
  340. else
  341. return nil;
  342. % Both formulas are incongruences
  343. if remainder(m,n) = 0 then
  344. return {'(delete . T)}
  345. else if remainder(n,m) = 0 then
  346. return {'(delete . nil)}
  347. else
  348. return nil;
  349. end;
  350. procedure pasf_susibinord(oop,ot,oabs,nop,nt,nabs,level);
  351. % Presburger arithmetic standard form additive simplification.
  352. % [oop] and [nop] are the old and the new relation operators; [ot]
  353. % and [nt] are the corresponding lefthand sides of the terms;
  354. % [oabs] and [nabs] are the corresponding constant parts; [level]
  355. % is the recursion level. Returns a suseproc that simplifies the
  356. % two atomic formulas.
  357. begin scalar w;
  358. % Congruences are treated differently
  359. if pairp oop and pairp nop then
  360. if cdr oop = cdr nop then
  361. return pasf_susibinordcongeq(oop,nop)
  362. else
  363. return pasf_susibinordcong(oop,ot,oabs,nop,nt,nabs,level);
  364. % Nothing to do for congruences times order relations
  365. if pairp oop or pairp nop then
  366. return nil;
  367. w := pasf_smordtable(if pairp oop then car oop else oop,
  368. if pairp nop then car nop else nop,oabs,nabs);
  369. if car w eq nil then
  370. % Nothing can be done
  371. return nil
  372. else if car w eq 'false then
  373. % Contradiction found
  374. return 'false
  375. else if car w eq 1 then
  376. % Remove new atomic formula from the level
  377. return {'(delete . T)}
  378. else if car w eq 2 then
  379. % Remove old atomic formula from the theory, add new atomic
  380. % formula to the knowledge
  381. return {'(delete . nil)}
  382. end;
  383. procedure pasf_susibinordcongeq(oop,nop);
  384. % Presburger arithmetic standard form smart additive simplification
  385. % be equal lefthand terms in congruences with equai moduli.[oop]
  386. % and [nop] are the old and the new relation operators; [ot] and
  387. % [nt] are the corresponding lefthand sides of the terms; [oabs]
  388. % and [nabs] are the corresponding constant parts; [level] is the
  389. % recursion level. Returns a susiprog that simplifies the formula.
  390. begin
  391. scalar n,m;
  392. n := cdr oop;
  393. m := cdr nop;
  394. % Both formulas are congruences
  395. if car oop eq 'cong and car nop eq 'cong then
  396. return 'false;
  397. % Old formula is a congruence and new is a incongruence
  398. if car oop eq 'cong and car nop eq 'ncong then
  399. return {'(delete . T)};
  400. % Old formula is an incongruence and new is a congurence
  401. if car oop eq 'ncong and car nop eq 'cong then
  402. return {'(delete . nil)};
  403. % Both formulas are incongruences
  404. return nil;
  405. end;
  406. procedure pasf_susibinordcong(oop,ot,oabs,nop,nt,nabs,level);
  407. % Presburger arithmetic standard form smart additive simplification
  408. % be equal lefthand terms in congruences with different
  409. % moduli. [oop] and [nop] are the old and the new relation
  410. % operators; [ot] and [nt] are the corresponding lefthand sides of
  411. % the terms; [oabs] and [nabs] are the corresponding constant
  412. % parts; [level] is the recursion level. Returns a susiprog that
  413. % simplifies the formula.
  414. begin
  415. scalar n,m;
  416. n := cdr oop;
  417. m := cdr nop;
  418. % Both formulas are congruences
  419. if car oop eq 'cong and car nop eq 'cong then
  420. return nil;
  421. return nil;
  422. end;
  423. procedure pasf_susipost(atl,knowl);
  424. % Presburger arithmetic standad form susi post
  425. % simplification. [atl] is a list of atomic formulas. [knowl] is a
  426. % KNOWL. Returns a list $\lambda$ of atomic formulas, such that
  427. % $\bigwedge[knowl]\land\bigwedge\lambda$ is equivalent to
  428. % $\bigwedge[knowl]\and\bigwedge[atl]$
  429. atl;
  430. procedure pasf_susitf(at,knowl);
  431. % Presburger arithmetic standard form susi transform. [at] is an
  432. % atomic formula, [knowl] is a knowledge. Returns an atomic formula
  433. % $\alpha$ such that $\alpha\land\bigwedge[knowl]$ is equivalent to
  434. % $[at]\land\bigwedge[knowl]$. $\alpha$ has possibly a more
  435. % convenient relation than [at].
  436. at;
  437. procedure pasf_smeqtable(r1,r2);
  438. % Presburger arithmetic standard form smart simplify equal absolute
  439. % summands table. [r1], [r2] are relations. Returns [false] or a
  440. % relation $R$ such that $R(f+a,0)$ is equivalent to $[r1](f+a,0)
  441. % \land [r2](f+a,0)$.
  442. begin scalar al;
  443. al := '(
  444. (equal .
  445. ((equal . (1 . nil))
  446. (neq . (false . nil))
  447. (geq . (1 . nil))
  448. (leq . (1 . nil))
  449. (greaterp . (false . nil))
  450. (lessp . (false . nil))
  451. (cong . (1 . nil))
  452. (ncong . (false . nil))))
  453. (neq .
  454. ((equal . (false . nil))
  455. (neq . (1 . nil))
  456. (geq . (3 . greaterp))
  457. (leq . (3 . lessp))
  458. (greaterp . (2 . nil))
  459. (lessp . (2 . nil))
  460. (cong . (nil . nil))
  461. (ncong . (2 . nil))))
  462. (geq .
  463. ((equal . (2 . nil))
  464. (neq . (3 . greaterp))
  465. (geq . (1 . nil))
  466. (leq . (3 . equal))
  467. (greaterp . (2 . nil))
  468. (lessp . (false . nil))
  469. (cong . (nil . nil))
  470. (ncong . (5 . greaterp))))
  471. (leq .
  472. ((equal . (2 . nil))
  473. (neq . (3 . lessp))
  474. (geq . (3 . equal))
  475. (leq . (1 . nil))
  476. (greaterp . (false . nil))
  477. (lessp . (2 . nil))
  478. (cong . (nil . nil))
  479. (ncong . (5 . lessp))))
  480. (greaterp .
  481. ((equal . (false . nil))
  482. (neq . (1 . nil))
  483. (geq . (1 . nil))
  484. (leq . (false . nil))
  485. (greaterp . (1 . nil))
  486. (lessp . (false . nil))
  487. (cong . (nil . nil))
  488. (ncong . (nil . nil))))
  489. (lessp .
  490. ((equal . (false . nil))
  491. (neq . (1 . nil))
  492. (geq . (false . nil))
  493. (leq . (1 . nil))
  494. (greaterp . (false . nil))
  495. (lessp . (1 . nil))
  496. (cong . (nil . nil))
  497. (ncong . (nil . nil))))
  498. (cong .
  499. ((equal . (2 . nil))
  500. (neq . (nil . nil))
  501. (geq . (nil . nil))
  502. (leq . (nil . nil))
  503. (greaterp . (nil . nil))
  504. (lessp . (nil . nil))
  505. (cong . (1 . nil))
  506. (ncong . (nil . nil))))
  507. (ncong .
  508. ((equal . (false . nil))
  509. (neq . (1 . nil))
  510. (geq . (4 . greaterp))
  511. (leq . (4 . lessp))
  512. (greaterp . (nil . nil))
  513. (lessp . (nil . nil))
  514. (cong . (false . nil))
  515. (ncong . (1 . nil)))));
  516. return cdr (atsoc(r2,atsoc(r1,al)))
  517. end;
  518. procedure pasf_smordtable(r1,r2,s,tt);
  519. % Presburger arithmetic standard form smart simplify ordered
  520. % absolute summands. [r1], [r2] are relations, [s] is the constant
  521. % part of [r1], [t] is the one of [r2]. Returns $(nil . nil)$ if no
  522. % simplification is possible; $(false . nil)$ if contradiction was
  523. % found; $(1 . nil)$ if the new formula does not bring any
  524. % knowledge and can be so removed from the actual level; $(2
  525. % . nil)$ if the old formula should be removed and the new added.
  526. if minusf addf(s, negf tt) then
  527. % -s < -t => s > t
  528. pasf_smordtable2(r1,r2)
  529. else
  530. % -s > -t => s < t
  531. pasf_smordtable1(r1,r2);
  532. procedure pasf_smordtable1(r1,r2);
  533. % Presburger arithmetic standard form smart simplify ordered
  534. % absolute summands table if absoulte summand of [r1] is less as
  535. % the one of [r2].
  536. begin scalar al;
  537. al := '(
  538. (lessp .
  539. ((lessp . (1 . nil))
  540. (leq . (1 . nil))
  541. (equal . (false . nil))
  542. (neq . (1 . nil))
  543. (geq . (false . nil))
  544. (greaterp . (false . nil))
  545. (cong . (nil . nil))
  546. (ncong . (nil . nil))))
  547. (leq .
  548. ((lessp . (1 . nil))
  549. (leq . (1 . nil))
  550. (equal . (false . nil))
  551. (neq . (1 . nil))
  552. (geq . (false . nil))
  553. (greaterp . (false . nil))
  554. (cong . (nil . nil))
  555. (ncong . (nil . nil))))
  556. (equal .
  557. ((lessp . (1 . nil))
  558. (leq . (1 . nil))
  559. (equal . (false . nil))
  560. (neq . (1 . nil))
  561. (geq . (false . nil))
  562. (greaterp . (false . nil))
  563. (cong . (nil . nil))
  564. (ncong . (nil . nil))))
  565. (neq .
  566. ((lessp . (nil . nil))
  567. (leq . (nil . nil))
  568. (equal . (2 . nil))
  569. (neq . (nil . nil))
  570. (geq . (2 . nil))
  571. (greaterp . (2 . nil))
  572. (cong . (nil . nil))
  573. (ncong . (nil . nil))))
  574. (geq .
  575. ((lessp . (nil . nil))
  576. (leq . (nil . nil))
  577. (equal . (2 . nil))
  578. (neq . (nil . nil))
  579. (geq . (2 . nil))
  580. (greaterp . (2 . nil))
  581. (cong . (nil . nil))
  582. (ncong . (nil . nil))))
  583. (greaterp .
  584. ((lessp . (nil . nil))
  585. (leq . (nil . nil))
  586. (equal . (2 . nil))
  587. (neq . (nil . nil))
  588. (geq . (2 . nil))
  589. (greaterp . (2 . nil))
  590. (cong . (nil . nil))
  591. (ncong . (nil . nil))))
  592. (cong .
  593. ((lessp . (nil . nil))
  594. (leq . (nil . nil))
  595. (equal . (2 . nil))
  596. (neq . (nil . nil))
  597. (geq . (2 . nil))
  598. (greaterp . (2 . nil))
  599. (cong . (nil . nil))
  600. (ncong . (nil . nil))))
  601. (ncong .
  602. ((lessp . (nil . nil))
  603. (leq . (nil . nil))
  604. (equal . (nil . nil))
  605. (neq . (nil . nil))
  606. (geq . (nil . nil))
  607. (greaterp . (nil . nil))
  608. (cong . (nil . nil))
  609. (ncong . (nil . nil)))));
  610. return cdr (atsoc(r2,atsoc(r1,al)))
  611. end;
  612. procedure pasf_smordtable2(r1,r2);
  613. % Presburger arithmetic standard form smart simplify ordered
  614. % absolute summands table if absoulte summand of [r1] is less as
  615. % the one of [r2].
  616. begin scalar al;
  617. al := '(
  618. (lessp .
  619. ((lessp . (2 . nil))
  620. (leq . (2 . nil))
  621. (equal . (2 . nil))
  622. (neq . (nil . nil))
  623. (geq . (nil . nil))
  624. (greaterp . (nil . nil))
  625. (cong . (nil . nil))
  626. (ncong . (nil . nil))))
  627. (leq .
  628. ((lessp . (2 . nil))
  629. (leq . (2 . nil))
  630. (equal . (2 . nil))
  631. (neq . (nil . nil))
  632. (geq . (nil . nil))
  633. (greaterp . (nil . nil))
  634. (cong . (nil . nil))
  635. (ncong . (nil . nil))))
  636. (equal .
  637. ((lessp . (false . nil))
  638. (leq . (false . nil))
  639. (equal . (false . nil))
  640. (neq . (1 . nil))
  641. (geq . (1 . nil))
  642. (greaterp . (1 . nil))
  643. (cong . (nil . nil))
  644. (ncong . (nil . nil))))
  645. (neq .
  646. ((lessp . (2 . nil))
  647. (leq . (2 . nil))
  648. (equal . (2 . nil))
  649. (neq . (nil . nil))
  650. (geq . (nil . nil))
  651. (greaterp . (nil . nil))
  652. (cong . (nil . nil))
  653. (ncong . (nil . nil))))
  654. (geq .
  655. ((lessp . (false . nil))
  656. (leq . (false . nil))
  657. (equal . (false . nil))
  658. (neq . (1 . nil))
  659. (geq . (1 . nil))
  660. (greaterp . (1 . nil))
  661. (cong . (nil . nil))
  662. (ncong . (nil . nil))))
  663. (greaterp .
  664. ((lessp . (false . nil))
  665. (leq . (false . nil))
  666. (equal . (false . nil))
  667. (neq . (1 . nil))
  668. (geq . (1 . nil))
  669. (greaterp . (1 . nil))
  670. (cong . (nil . nil))
  671. (ncong . (nil . nil))))
  672. (cong .
  673. ((lessp . (nil . nil))
  674. (leq . (nil . nil))
  675. (equal . (nil . nil))
  676. (neq . (nil . nil))
  677. (geq . (nil . nil))
  678. (greaterp . (nil . nil))
  679. (cong . (nil . nil))
  680. (ncong . (nil . nil))))
  681. (ncong .
  682. ((lessp . (nil . nil))
  683. (leq . (nil . nil))
  684. (equal . (nil . nil))
  685. (neq . (nil . nil))
  686. (geq . (nil . nil))
  687. (greaterp . (nil . nil))
  688. (cong . (nil . nil))
  689. (ncong . (nil . nil)))));
  690. return cdr (atsoc(r2,atsoc(r1,al)))
  691. end;
  692. procedure pasf_smtrtable(r1,r2);
  693. % Presburger arithmetic standard form smart transitive
  694. % simplification table. [r1] is the theory relation; [r2] is the
  695. % new level relation. Returns a new transitive concluded relation
  696. % or nil if no conclusion can be done.
  697. begin scalar al;
  698. % For these operations no transitive simplification is done
  699. if r1 memq '(neq greaterp cong ncong) then
  700. return nil;
  701. al := '(
  702. (equal .
  703. ((equal . equal)
  704. (greaterp . lessp)
  705. (geq . leq)
  706. (leq . nil)
  707. (lessp . nil)
  708. (neq . nil)
  709. (cong . nil)
  710. (ncong . nil)))
  711. (lessp .
  712. ((equal . lessp)
  713. (greaterp . lessp)
  714. (geq . lessp)
  715. (leq . nil)
  716. (lessp . nil)
  717. (neq . nil)
  718. (cong . nil)
  719. (ncong . nil)))
  720. (geq .
  721. ((equal . nil)
  722. (greaterp . nil)
  723. (geq . nil)
  724. (leq . nil)
  725. (lessp . nil)
  726. (neq . nil)
  727. (cong . nil)
  728. (ncong . nil)))
  729. (leq .
  730. ((equal . leq)
  731. (greaterp . lessp)
  732. (geq . leq)
  733. (leq . nil)
  734. (lessp . nil)
  735. (neq . nil)
  736. (cong . nil)
  737. (ncong . nil))));
  738. return cdr (atsoc(r2,atsoc(r1,al)))
  739. end;
  740. endmodule; % [pasfsism]
  741. end; % of file