ofsfbnf.red 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. % ----------------------------------------------------------------------
  2. % $Id: ofsfbnf.red,v 1.4 1999/03/23 07:41:37 dolzmann Exp $
  3. % ----------------------------------------------------------------------
  4. % Copyright (c) 1995-1999 Andreas Dolzmann and Thomas Sturm
  5. % ----------------------------------------------------------------------
  6. % $Log: ofsfbnf.red,v $
  7. % Revision 1.4 1999/03/23 07:41:37 dolzmann
  8. % Changed copyright information.
  9. %
  10. % Revision 1.3 1999/03/21 13:38:04 dolzmann
  11. % Removed procedure acfsf_bnfsimpl which was identical to cl_bnfsimpl.
  12. %
  13. % Revision 1.2 1996/10/07 12:03:22 sturm
  14. % Added fluids for CVS and copyright information.
  15. %
  16. % Revision 1.1 1996/03/22 12:14:02 sturm
  17. % Moved and split.
  18. %
  19. % ----------------------------------------------------------------------
  20. lisp <<
  21. fluid '(ofsf_bnf_rcsid!* ofsf_bnf_copyright!*);
  22. ofsf_bnf_rcsid!* := "$Id: ofsfbnf.red,v 1.4 1999/03/23 07:41:37 dolzmann Exp $";
  23. ofsf_bnf_copyright!* := "Copyright (c) 1995-1999 by A. Dolzmann and T. Sturm"
  24. >>;
  25. module ofsfbnf;
  26. % Ordered field standard form boolean normal forms. Submodule of [ofsf].
  27. procedure ofsf_dnf(f);
  28. % Ordered field standard form conjunctive normal form. [f] is a
  29. % formula. Returns a DNF of [f].
  30. if !*rlbnfsac then
  31. (cl_dnf f) where !*rlsiso=T
  32. else
  33. cl_dnf f;
  34. procedure ofsf_cnf(f);
  35. % Ordered field standard form conjunctive normal form. [f] is a
  36. % formula. Returns a CNF of [f].
  37. if !*rlbnfsac then
  38. (cl_cnf f) where !*rlsiso=T
  39. else
  40. cl_cnf f;
  41. procedure ofsf_subsumption(l1,l2,gor);
  42. % Ordered field standard form subsume. [l1] and [l2] are lists of
  43. % atomic formulas. Returns one of [imp], [rep], [nil].
  44. if gor eq 'or then (
  45. if ofsf_subsumep!-and(l1,l2) then
  46. 'keep2
  47. else if ofsf_subsumep!-and(l2,l1) then
  48. 'keep1
  49. ) else % [gor eq 'and]
  50. if ofsf_subsumep!-or(l1,l2) then
  51. 'keep1
  52. else if ofsf_subsumep!-or(l2,l1) then
  53. 'keep2;
  54. procedure ofsf_subsumep!-and(l1,l2);
  55. % Ordered field standard form subsume [and] case. [l1] and [l2] are
  56. % lists of atomic formulas.
  57. begin scalar a;
  58. while l2 do <<
  59. a := car l2;
  60. l2 := cdr l2;
  61. if cl_simpl(a,l1,-1) neq 'true then a := l2 := nil
  62. >>;
  63. return a
  64. end;
  65. procedure ofsf_subsumep!-or(l1,l2);
  66. % Ordered field standard form subsume [or] case. [l1] and [l2] are
  67. % lists of atomic formulas.
  68. begin scalar a;
  69. while l1 do <<
  70. a := car l1;
  71. l1 := cdr l1;
  72. if cl_simpl(rl_smkn('or,l2),{a},-1) neq 'true then a := l1 := nil
  73. >>;
  74. return a
  75. end;
  76. procedure ofsf_sacatlp(a,l);
  77. % Ordered field standard form subsume and cut atomic formula list
  78. % predicate. [a] is an atomic formula; [l] is a list of atomic
  79. % formulas. [T] is returned if a subsumption or cut beween [a] and
  80. % an element of [l] is possible.
  81. not ((ofsf_arg2l a neq ofsf_arg2l w) and ordp(ofsf_arg2l a,ofsf_arg2l w))
  82. where w=car l;
  83. procedure ofsf_sacat(a1,a2,gor);
  84. % Ordered field standard form subsume and cut atomic formula. [a1]
  85. % and [a2] are atomic formulas; [gor] is one of [or], [and].
  86. % Returns [nil], ['keep], ['keep2], ['keep1], ['drop], or an atomic
  87. % formula. If [nil] is returned then neither a cut nor a
  88. % subsumption can be applied, if [keep] is returned then the atomic
  89. % formuas are identical, in the case of [keep1] or [keep2] the
  90. % respective atomic formula must be kept but the other can be
  91. % dropped. If an atomic formula $a$ is returned then it is the
  92. % result of the cut beween [a1] and [a2], if ['drop] is returned, a
  93. % cut with result ['true] or ['false] can be performed.
  94. begin scalar w;
  95. if ofsf_arg2l a1 neq ofsf_arg2l a2 then return nil;
  96. w := ofsf_sacrel(ofsf_op a1, ofsf_op a2,gor);
  97. if w memq '(drop keep keep1 keep2) then return w;
  98. return ofsf_0mk2(w,ofsf_arg2l a1)
  99. end;
  100. procedure ofsf_sacrel(r1,r2,gor);
  101. % Ordered field standard form subsume and cut relation. [r1] and
  102. % [r2] are relations; [gor] is one of [or], [and]. Returns ['keep],
  103. % ['keep2], ['keep1], ['drop], or a relation. [r1] and [r2] are
  104. % considered as relations of atomic formulas $[r1](t,0)$ and
  105. % $[r2](t,0)$. If [keep] is returned then the atomic formulas are
  106. % identical, in the case of [keep1] or [keep2] the respective
  107. % atomic formula must be kept but the other can be dropped, if a
  108. % relation $\rho$ is returned a cut with result $t\rho 0$ can be
  109. % performed, where $t$ is the left hand side of [a1] and [a2], if
  110. % ['drop] is returned, a cut with result ['true] or ['false] can be
  111. % performed.
  112. if gor eq 'or then
  113. ofsf_sacrel!-or(r1,r2)
  114. else
  115. ofsf_sacrel!-and(r1,r2);
  116. procedure ofsf_sacrel!-or(r1,r2);
  117. % Ordered field standard form subsume and cut relation or. [r1] and
  118. % [r2] are relations. ['keep], ['keep2], ['keep1], ['drop], or a
  119. % relation is returned. [r1] and [r2] are considered as relations
  120. % of atomic formulas $[r1](t,0)$ and $[r2](t,0)$. If [keep] is
  121. % returned then the atomic formulas are identical, in the case of
  122. % [keep1] or [keep2] the respective atomic formula must be kept but
  123. % the other can be dropped, if a relation $\rho$ is returned a cut
  124. % with result $t\rho 0$ can be performed, where $t$ is the left
  125. % hand side of [a1] and [a2], if ['drop] is returned a cut with
  126. % result ['true] can be performed.
  127. begin scalar w;
  128. w:= '( (lessp . ( (lessp . keep) (leq . keep1) (equal . leq)
  129. (neq . keep1) (geq . drop) (greaterp . neq)))
  130. (leq . ( (lessp . keep2) (leq . keep) (equal . keep2)
  131. (neq . drop) (geq . drop) (greaterp . drop)))
  132. (equal . ( (lessp . leq) (leq . keep1) (equal . keep)
  133. (neq . drop) (geq . keep1) (greaterp . geq)))
  134. (neq . ( (lessp . keep2) (leq . drop) (equal . drop)
  135. (neq . keep) (geq . drop) (greaterp . keep2)))
  136. (geq . ( (lessp . drop) (leq . drop) (equal . keep2)
  137. (neq . drop) (geq . keep) (greaterp . keep2)))
  138. (greaterp . ( (lessp . neq) (leq . drop) (equal . geq)
  139. (neq . keep1) (geq . keep1) (greaterp . keep))));
  140. return cdr atsoc(r1,cdr atsoc(r2,w));
  141. end;
  142. procedure ofsf_sacrel!-and(r1,r2);
  143. % Ordered field standard form subsume and cut relation and. [r1] and
  144. % [r2] are relations. ['keep], ['keep2], ['keep1], ['drop], or a
  145. % relation is returned. [r1] and [r2] are considered as relations
  146. % of atomic formulas $[r1](t,0)$ and $[r2](t,0)$. If [keep] is
  147. % returned then the atomic formulas are identical, in the case of
  148. % [keep1] or [keep2] the respective atomic formula must be kept but
  149. % the other can be dropped, if a relation $\rho$ is returned a cut
  150. % with result $t\rho 0$ can be performed, where $t$ is the left
  151. % hand side of [a1] and [a2], if ['drop] is returned a cut with
  152. % result ['false] can be performed.
  153. begin scalar w;
  154. w:= '( (lessp . ( (lessp . keep) (leq . keep2) (equal . drop)
  155. (neq . keep2) (geq . drop) (greaterp . drop)))
  156. (leq . ( (lessp . keep1) (leq . keep) (equal . keep1)
  157. (neq . lessp) (geq . equal) (greaterp . drop)))
  158. (equal . ( (lessp . drop) (leq . keep2) (equal . keep)
  159. (neq . drop) (geq . keep2) (greaterp . drop)))
  160. (neq . ( (lessp . keep1) (leq . lessp) (equal . drop)
  161. (neq . keep) (geq . greaterp) (greaterp . keep1)))
  162. (geq . ( (lessp . drop) (leq . equal) (equal . keep1)
  163. (neq . greaterp) (geq . keep) (greaterp . keep1)))
  164. (greaterp . ( (lessp . drop) (leq . drop) (equal . drop)
  165. (neq . keep2) (geq . keep2) (greaterp . keep))));
  166. return cdr atsoc(r1,cdr atsoc(r2,w));
  167. end;
  168. endmodule; % [ofsfbnf]
  169. end; % of file