dvfsfsism.red 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. % ----------------------------------------------------------------------
  2. % $Id: dvfsfsism.red,v 1.3 1999/05/06 12:18:41 sturm Exp $
  3. % ----------------------------------------------------------------------
  4. % Copyright (c) 1995-1999 Andreas Dolzmann and Thomas Sturm
  5. % ----------------------------------------------------------------------
  6. % $Log: dvfsfsism.red,v $
  7. % Revision 1.3 1999/05/06 12:18:41 sturm
  8. % Updated comments for exported procedures.
  9. %
  10. % Revision 1.2 1999/03/23 08:47:12 dolzmann
  11. % Changed copyright information.
  12. % Corrected comments for extracting with exc.
  13. %
  14. % Revision 1.1 1999/03/21 13:36:50 dolzmann
  15. % Initial check-in.
  16. % Smart simplification for discretely valued fields based on susi.
  17. %
  18. % ----------------------------------------------------------------------
  19. lisp <<
  20. fluid '(dvfsf_sism_rcsid!* dvfsf_sism_copyright!*);
  21. dvfsf_sism_rcsid!* :=
  22. "$Id: dvfsfsism.red,v 1.3 1999/05/06 12:18:41 sturm Exp $";
  23. dvfsf_sism_copyright!* := "Copyright (c) 1995-1999 A. Dolzman and T. Sturm"
  24. >>;
  25. module dvfsfsism;
  26. % Discretely valued field standard form simplify smart. Submodule of
  27. % [dvfsf]. This module provides the black boxes [rl_smupdknowl],
  28. % [rl_smrmknowl], [rl_smcpknowl], [rl_smmkatl], and [rl_susirmknowl]
  29. % to [cl_simpl]. They are used with switch [rlsism] on.
  30. procedure dvfsf_smupdknowl(op,atl,knowl,n);
  31. % Discretely valued field smart simplification update knowledge.
  32. % [op] is one of [and], [or]; [atl] is a list of (simplified)
  33. % atomic formulas; [knowl] is a conjunctive IRL; [n] is the current
  34. % level. Returns an IRL. Destructively updates [knowl] wrt. the
  35. % [atl] information. Accesses the switch [rlsusi].
  36. if !*rlsusi then
  37. cl_susiupdknowl(op,atl,knowl,n)
  38. else
  39. cl_smupdknowl(op,atl,knowl,n);
  40. procedure dvfsf_smrmknowl(knowl,v);
  41. % Discretely valued field smart simplification remove from
  42. % knowledge. [knowl] is an IRL; [v] is a variable. Returns an IRL.
  43. % Destructively removes all information about [v] from [knowl].
  44. % Accesses the switch [rlsusi].
  45. if !*rlsusi then
  46. dvfsf_susirmknowl(knowl,v)
  47. else
  48. cl_smrmknowl(knowl,v);
  49. procedure dvfsf_smcpknowl(knowl);
  50. % Discretely valued field smart simplification copy knowledge.
  51. % [knowl] is an IRL. Returns an IRL. Copies [knowl]. Accesses the
  52. % switch [rlsusi].
  53. if !*rlsusi then
  54. cl_susicpknowl(knowl)
  55. else
  56. cl_smcpknowl(knowl);
  57. procedure dvfsf_smmkatl(op,knowl,newknowl,n);
  58. % Discretely valued field smart simplification make atomic formula
  59. % list. [op] is one of [and], [or]; [oldknowl] and [newknowl] are
  60. % IRL's; [n] is an integer. Returns a list of atomic formulas.
  61. % Accesses the switch [rlsusi].
  62. if !*rlsusi then
  63. cl_susimkatl(op,knowl,newknowl,n)
  64. else
  65. cl_smmkatl(op,knowl,newknowl,n);
  66. procedure dvfsf_susirmknowl(knowl,v);
  67. % Discretely valued field susi remove knowledge. [knowl] is a
  68. % KNOWL; [v] is a variable. Returns a KNOWL. Remove all information
  69. % about [v] from [knowl].
  70. for each p in knowl join
  71. if v memq dvfsf_varlat car p then nil else {p};
  72. procedure dvfsf_susibin(old,new);
  73. % Discretely valued field standard form susi binary smart simplification.
  74. % [old] and [new] are LAT's. Returns ['false] or a SUSIPRG. We
  75. % assume that [old] is a part of a already existence KNOWL and new
  76. % has to be added to this KNOWL.
  77. begin scalar oop,olhs,orhs,olev,nop,nlhs,nrhs,nlev,!*rlsiexpl;
  78. olev := cdr old;
  79. old := car old;
  80. oop := dvfsf_op old;
  81. olhs := dvfsf_arg2l old;
  82. orhs := dvfsf_arg2r old;
  83. nlev := cdr new;
  84. new := car new;
  85. nop := dvfsf_op new;
  86. nlhs := dvfsf_arg2l new;
  87. nrhs := dvfsf_arg2r new;
  88. if olhs = nlhs and orhs = nrhs then
  89. return dvfsf_susibin1(oop,nop,nlhs,nrhs,nlev);
  90. if (olhs = nrhs and orhs = nlhs) then
  91. % [oop], [noop] cannot be [equal], [neq]
  92. return dvfsf_susibin2(oop,nop,nlhs,nrhs,nlev);
  93. if (oop eq 'equal or oop eq 'neq) and nop neq 'equal and nop neq 'neq and
  94. dvfsf_susibin!-eqlhsmatch(nlhs,nrhs,olhs)
  95. then
  96. return dvfsf_susibin1(oop,nop,nlhs,nrhs,nlev);
  97. if (nop eq 'equal or nop eq 'neq) and oop neq 'equal and oop neq 'neq and
  98. dvfsf_susibin!-eqlhsmatch(olhs,orhs,nlhs)
  99. then
  100. return dvfsf_susibin1(oop,nop,olhs,orhs,nlev);
  101. return nil
  102. end;
  103. procedure dvfsf_susibin!-eqlhsmatch(lhs,rhs,eqlhs);
  104. % Discretely valued field standard form super simplifier binary
  105. % smart simplification equal left hand side match. Check if
  106. % $[lhs]-[rhs]=[eqlhs]$.
  107. begin scalar w;
  108. w := dvfsf_simplat1(dvfsf_0mk2('equal,addf(lhs,negf rhs)),nil);
  109. if not rl_tvalp w then
  110. return dvfsf_arg2l w = eqlhs;
  111. return nil
  112. end;
  113. procedure dvfsf_susibin1(rold,rnew,lhs,rhs,nlev);
  114. if rold eq rnew then
  115. '((delete . t))
  116. else if rold eq 'neq then
  117. if rnew eq 'equal then
  118. 'false
  119. else if rnew eq 'sdiv or rnew eq 'nassoc then
  120. '((delete . nil))
  121. else
  122. nil
  123. else if rold eq 'sdiv then
  124. if rnew eq 'neq or rnew eq 'div or rnew eq 'nassoc then
  125. '((delete . t))
  126. else % [rnew memq '(assoc equal)]
  127. 'false
  128. else if rold eq 'div then
  129. if rnew eq 'sdiv or rnew eq 'assoc or rnew eq 'equal then
  130. '((delete . nil))
  131. else if rnew eq 'nassoc then
  132. {'(delete . nil),'(delete . t),
  133. 'add . (dvfsf_mk2('sdiv,lhs,rhs) . nlev)}
  134. else
  135. nil
  136. else if rold eq 'assoc then
  137. if rnew eq 'sdiv or rnew eq 'nassoc then
  138. 'false
  139. else if rnew eq 'div then
  140. '((delete . t))
  141. else if rnew eq 'equal then
  142. '((delete . nil))
  143. else % [rnew eq 'neq]
  144. nil
  145. else if rold eq 'equal then
  146. if rnew eq 'neq or rnew eq 'sdiv or rnew eq 'nassoc then
  147. 'false
  148. else % [rnew memq '(div, assoc)]
  149. '((delete . t))
  150. else if rold eq 'nassoc then
  151. if rnew eq 'sdiv then
  152. '((delete . nil))
  153. else if rnew eq 'assoc or rnew eq 'equal then
  154. 'false
  155. else if rnew eq 'div then
  156. {'(delete . nil),'(delete . t),
  157. 'add . (dvfsf_mk2('sdiv,lhs,rhs) . nlev)}
  158. else % [rnew eq 'neq]
  159. '((delete . t))
  160. else
  161. rederr {"BUG IN dvfsf_susibin1(",rold,",",rnew,")"};
  162. procedure dvfsf_susibin2(rold,rnew,nlhs,nrhs,nlev);
  163. % Smart simplification with crossed sides. Assumed to be called
  164. % with valuation relations only, and also not with two of the
  165. % symmetric relations [assoc], [nassoc].
  166. if rold eq 'div then
  167. if rnew eq 'sdiv then
  168. 'false
  169. else if rnew eq 'div then
  170. {'(delete . nil),'(delete . t),
  171. 'add . (dvfsf_simplat1(dvfsf_mk2('assoc,nlhs,nrhs),nil) . nlev)}
  172. else if rnew eq 'assoc then
  173. '((delete . nil))
  174. else if rnew eq 'nassoc then
  175. {'(delete . nil),'(delete . t),
  176. 'add . (dvfsf_mk2('sdiv,nrhs,nlhs) . nlev)}
  177. else
  178. nil
  179. else if rold eq 'sdiv then
  180. if rnew eq 'div or rnew eq 'sdiv or rnew eq 'assoc then
  181. 'false
  182. else if rnew eq 'nassoc then
  183. '((delete . t))
  184. else
  185. nil
  186. else if rold eq 'nassoc then
  187. if rnew eq 'sdiv then
  188. '((delete . nil))
  189. else if rnew eq 'div then
  190. {'(delete . nil),'(delete . t),
  191. 'add . (dvfsf_mk2('sdiv,nlhs,nrhs) . nlev)}
  192. else
  193. nil
  194. else if rold eq 'assoc then
  195. if rnew eq 'sdiv then
  196. 'false
  197. else if rnew eq 'div then
  198. '((delete . t))
  199. else
  200. nil
  201. else
  202. nil;
  203. procedure dvfsf_susipost(atl,knowl);
  204. % Discretely valued field standad form susi post simplification. [atl] is a
  205. % list of atomic formulas. [knowl] is a KNOWL. Returns a list
  206. % $\lambda$ of atomic formulas, such that
  207. % $\bigwedge[knowl]\land\bigwedge\lambda$ is equivalent to
  208. % $\bigwedge[knowl]\land\bigwedge[atl]$
  209. atl;
  210. procedure dvfsf_susitf(at,knowl);
  211. % Discretely valued field standard form susi transform. [at] is an
  212. % atomic formula, [knowl] is a knowledge. Returns an atomic formula
  213. % $\alpha$ such that $\alpha\land\bigwedge[knowl]$ is equivalent to
  214. % $[at]\land\bigwedge[knowl]$. $\alpha$ has possibly a more
  215. % convenient relation than [at].
  216. at;
  217. endmodule; % [dvfsfsism]
  218. end; % of file