dvfsfsism.red 6.9 KB

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