acfsfsism.red 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. % ----------------------------------------------------------------------
  2. % $Id: acfsfsism.red,v 1.3 1999/04/12 09:26:00 sturm Exp $
  3. % ----------------------------------------------------------------------
  4. % Copyright (c) 1995-1999 Andreas Dolzmann and Thomas Sturm
  5. % ----------------------------------------------------------------------
  6. % $Log: acfsfsism.red,v $
  7. % Revision 1.3 1999/04/12 09:26:00 sturm
  8. % Updated comments for exported procedures.
  9. %
  10. % Revision 1.2 1999/03/23 08:05:19 dolzmann
  11. % Changed copyright information.
  12. % Added fluids for the rcsid of the file and for the copyright information.
  13. %
  14. % Revision 1.1 1997/08/22 17:30:42 sturm
  15. % Created an acfsf context based on ofsf.
  16. %
  17. % ----------------------------------------------------------------------
  18. lisp <<
  19. fluid '(acfsf_sism_rcsid!* acfsf_sism_copyright!*);
  20. acfsf_sism_rcsid!* :=
  21. "$Id: acfsfsism.red,v 1.3 1999/04/12 09:26:00 sturm Exp $";
  22. acfsf_sism_copyright!* := "Copyright (c) 1995-1999 A. Dolzmann and T. Sturm"
  23. >>;
  24. module acfsfsism;
  25. % Algebraically closed field standard form smart simplification.
  26. % Submodule of [acfsf].
  27. %DS
  28. % <IRL> ::= (<IR>,...)
  29. % <IR> ::= <PARA> . <DB>
  30. % <DB> ::= (<LE>,...)
  31. % <LE> ::= <LABEL> . <ENTRY>
  32. % <LABEL> ::= <INTEGER>
  33. % <ENTRY> ::= <ACFSF RELATION> . <STANDARD QUOTIENT>
  34. procedure acfsf_smrmknowl(knowl,v);
  35. % Algebraically closed field smart simplification remove from
  36. % knowledge. [knowl] is an IRL; [v] is a variable. Returns an IRL.
  37. % Destructively removes all information about [v] from [knowl].
  38. if null knowl then
  39. nil
  40. else if v member kernels caar knowl then
  41. acfsf_smrmknowl(cdr knowl,v)
  42. else <<
  43. cdr knowl := acfsf_smrmknowl(cdr knowl,v);
  44. knowl
  45. >>;
  46. procedure acfsf_smcpknowl(knowl);
  47. % Algebraically closed field smart simplification copy knowledge.
  48. % [knowl] is an IRL. Returns an IRL. Copies [knowl] and the
  49. % contained IR's and DB's.
  50. for each ir in knowl collect
  51. car ir . append(cdr ir,nil);
  52. procedure acfsf_smupdknowl(op,atl,knowl,n);
  53. % Algebraically closed field smart simplification update knowledge.
  54. % [op] is one of [and], [or]; [atl] is a list of (simplified)
  55. % atomic formulas; [knowl] is a conjunctive IRL; [n] is the current
  56. % level. Returns an IRL. Destructively updates [knowl] wrt. the
  57. % [atl] information.
  58. begin scalar w,ir,a;
  59. while atl do <<
  60. a := if op eq 'and then car atl else acfsf_negateat car atl;
  61. atl := cdr atl;
  62. ir := acfsf_at2ir(a,n);
  63. if w := assoc(car ir,knowl) then <<
  64. cdr w := acfsf_sminsert(cadr ir,cdr w);
  65. if cdr w eq 'false then <<
  66. atl := nil;
  67. knowl := 'false
  68. >> % else [acfsf_sminsert] has updated [cdr w] destructively.
  69. >> else
  70. knowl := ir . knowl
  71. >>;
  72. return knowl
  73. end;
  74. procedure acfsf_smmkatl(op,oldknowl,newknowl,n);
  75. % Algebraically closed field smart simplification make atomic
  76. % formula list. [op] is one of [and], [or]; [oldknowl] and
  77. % [newknowl] are IRL's; [n] is an integer. Returns a list of atomic
  78. % formulas.
  79. acfsf_irl2atl(op,newknowl,n);
  80. procedure acfsf_smdbgetrel(abssq,db);
  81. if abssq = cddar db then
  82. cadar db
  83. else if cdr db then
  84. acfsf_smdbgetrel(abssq,cdr db);
  85. procedure acfsf_at2ir(atf,n);
  86. % Algebraically closed field standard form atomic formula to IR.
  87. % [atf] is an atomic formula; [n] is an integer. Returns the IR
  88. % representing [atf] on level [n].
  89. begin scalar op,par,abs,c;
  90. op := acfsf_op atf;
  91. abs := par := acfsf_arg2l atf;
  92. while not domainp abs do abs := red abs;
  93. par := addf(par,negf abs);
  94. c := sfto_dcontentf(par);
  95. par := quotf(par,c);
  96. abs := quotsq(!*f2q abs,!*f2q c);
  97. return par . {n . (op . abs)}
  98. end;
  99. procedure acfsf_irl2atl(op,irl,n);
  100. % Algebraically closed field standard form IRL to atomic formula
  101. % list. [irl] is an IRL; [n] is an integer. Returns a list of
  102. % atomic formulas containing the level-[n] atforms encoded in IRL.
  103. for each ir in irl join acfsf_ir2atl(op,ir,n);
  104. procedure acfsf_ir2atl(op,ir,n);
  105. (for each le in cdr ir join
  106. if car le = n then {acfsf_entry2at(op,cdr le,a)}) where a=!*f2q car ir;
  107. procedure acfsf_entry2at(op,entry,parasq);
  108. if !*rlidentify then
  109. cl_identifyat acfsf_entry2at1(op,entry,parasq)
  110. else
  111. acfsf_entry2at1(op,entry,parasq);
  112. procedure acfsf_entry2at1(op,entry,parasq);
  113. acfsf_0mk2(acfsf_clnegrel(car entry,op eq 'and),
  114. numr addsq(parasq,cdr entry));
  115. procedure acfsf_sminsert(le,db);
  116. % Algebraically closed field standard form smart simplify insert.
  117. % [le] is a marked entry; [db] is a database. Returns a database.
  118. % Destructively inserts [le] into [db].
  119. begin scalar a,w,scdb,oscdb;
  120. repeat <<
  121. w := acfsf_sminsert1(cadr car db,cddr car db,cadr le,cddr le,car le);
  122. if w and not idp w then << % identifiers [false] and [true] possible.
  123. db := cdr db;
  124. le := w
  125. >>
  126. >> until null w or idp w or null db;
  127. if w eq 'false then return 'false;
  128. if w eq 'true then return db;
  129. if null db then return {le};
  130. oscdb := db;
  131. scdb := cdr db;
  132. while scdb do <<
  133. a := car scdb;
  134. scdb := cdr scdb;
  135. w := acfsf_sminsert1(cadr a,cddr a,cadr le,cddr le,car le);
  136. if w eq 'true then <<
  137. scdb := nil;
  138. a := 'true
  139. >> else if w eq 'false then <<
  140. scdb := nil;
  141. a := 'false
  142. >> else if w then <<
  143. cdr oscdb := scdb;
  144. le := w
  145. >> else
  146. oscdb := cdr oscdb
  147. >>;
  148. if a eq 'false then return 'false;
  149. if a eq 'true then return db;
  150. return le . db
  151. end;
  152. procedure acfsf_sminsert1(r1,a,r2,b,n);
  153. % Algebraically closed field standard form smart simplify insert.
  154. % [r1], [r2] are relations, [a], [b] are absolute summands in SQ
  155. % representation; [n] is the current level. Returns [nil], [false],
  156. % [true], or a marked entry. Simplification of $\alpha=[r2](f+b,0)$
  157. % under the condition $\gamma=[r1](f+a,0)$ is considered: [nil]
  158. % means there is no simplification posssible; [true] means that
  159. % $\gamma$ implies $\alpha$; [false] means that $\alpha$
  160. % contradicts $\gamma$; the atomic formula encoded by a resulting
  161. % marked entry wrt. $f$ is equivalent to $\alpha$ under $\gamma$.
  162. begin scalar w,diff,n;
  163. diff := numr subtrsq(a,b);
  164. if null diff then <<
  165. w := acfsf_smeqtable(r1,r2);
  166. if w eq 'false then return 'false;
  167. % [w eq r1]
  168. return 'true
  169. >>;
  170. if minusf diff then <<
  171. w := acfsf_smordtable(r1,r2);
  172. if atom w then return w;
  173. if eqcar(w,r1) and cdr w then return 'true;
  174. return n . (car w . if cdr w then a else b)
  175. >>;
  176. w := acfsf_smordtable(r2,r1);
  177. if atom w then return w;
  178. if eqcar(w,r1) and null cdr w then return 'true;
  179. return n . (car w . if cdr w then b else a)
  180. end;
  181. procedure acfsf_smeqtable(r1,r2);
  182. % Algebraically closed field standard form smart simplify equal
  183. % absolute summands table. [r1], [r2] are relations. Returns
  184. % [false] or a relation $R$ such that $R(f+a,0)$ is equivalent to
  185. % $[r1](f+a,0) \land [r2](f+a,0)$.
  186. if r1 eq r2 then r1 else 'false;
  187. procedure acfsf_smordtable(r1,r2);
  188. % Algebraically closed field standard form smart simplify ordered
  189. % absolute summands table. [r1], [r2] are relations. Returns [nil],
  190. % which means that no simplification is possible, [false] or a pair
  191. % $R . s$ where $R$ is a relation and $s$ is one of [T], [nil]. For
  192. % absolute summands $a<b$ we have $[r1](f+a,0) \land [r2](f+b,0)$
  193. % equivalent to $R(f+a,0)$ in case $[s]=[T]$ or to $R(f+b,0)$ in
  194. % case $[s]=[nil]$.
  195. if r1 eq 'equal and r2 eq 'equal then
  196. 'false
  197. else if r1 neq r2 then
  198. 'equal . (r1 eq 'equal);
  199. endmodule; % [acfsfsism]
  200. end; % of file