dcfsf.red 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. % ----------------------------------------------------------------------
  2. % $Id: dcfsf.red,v 1.1 2004/03/22 12:31:49 sturm Exp $
  3. % ----------------------------------------------------------------------
  4. % Copyright (c) 2004 Thomas Sturm
  5. % ----------------------------------------------------------------------
  6. % $Log: dcfsf.red,v $
  7. % Revision 1.1 2004/03/22 12:31:49 sturm
  8. % Initial check-in.
  9. % Mostly copied from acfsf.
  10. % Includes Diploma Thesis by Kacem plus wrapper for this.
  11. %
  12. % ----------------------------------------------------------------------
  13. lisp <<
  14. fluid '(dcfsf_rcsid!* dcfsf_copyright!*);
  15. dcfsf_rcsid!* := "$Id: dcfsf.red,v 1.1 2004/03/22 12:31:49 sturm Exp $";
  16. dcfsf_copyright!* := "Copyright (c) 2004 T. Sturm"
  17. >>;
  18. module dcfsf;
  19. % Diferentially closed field standard form. Main module. Algorithms on
  20. % first-order formulas over diferentially closed fields. The language
  21. % contains binary relations ['equal], ['neq], ring operations and a
  22. % binary derivative operator ['d].
  23. create!-package('(dcfsf dcfsfmisc dcfsfqe dcfsfkacem),nil);
  24. load!-package 'rltools;
  25. load!-package 'cl;
  26. remflag('(load!-package),'eval); % for bootstrapping
  27. load!-package 'cgb;
  28. flag('(load!-package),'eval);
  29. load!-package 'acfsf;
  30. exports dcfsf_simpterm,dcfsf_prepat,dcfsf_resimpat,dcfsf_lengthat,
  31. dcfsf_chsimpat,dcfsf_simpat,dcfsf_op,dcfsf_arg2l,dcfsf_arg2r,dcfsf_argn,
  32. dcfsf_mk2,dcfsf_0mk2,dcfsf_mkn,dcfsf_opp;
  33. imports rltools,cl,cgb;
  34. fluid '(!*rlsiatadv !*rlsiexpl !*rlsiexpla !*rlgssub !*rlsiso !*rlgsrad
  35. !*rlgsred !*rlgsprod !*rlgserf !*rlverbose !*rlsifac !*rlbnfsac !*rlgsvb
  36. !*rlgsbnf !*rlgsutord !*rlnzden !*rladdcond !*rlqegen !*cgbgen !*cgbreal
  37. !*gbverbose dcfsf_gstv!* !*cgbverbose !*groebopt);
  38. flag('(dcfsf),'rl_package);
  39. % Parameters
  40. put('dcfsf,'rl_params,'(
  41. (rl_subat!* . dcfsf_subat)
  42. (rl_subalchk!* . dcfsf_subalchk)
  43. (rl_eqnrhskernels!* . dcfsf_eqnrhskernels)
  44. (rl_ordatp!* . dcfsf_ordatp)
  45. (rl_simplat1!* . acfsf_simplat1)
  46. (rl_smupdknowl!* . acfsf_smupdknowl)
  47. (rl_smrmknowl!* . acfsf_smrmknowl)
  48. (rl_smcpknowl!* . acfsf_smcpknowl)
  49. (rl_smmkatl!* . acfsf_smmkatl)
  50. (rl_smsimpl!-impl!* . cl_smsimpl!-impl)
  51. (rl_smsimpl!-equiv1!* . cl_smsimpl!-equiv1)
  52. (rl_negateat!* . dcfsf_negateat)
  53. (rl_varlat!* . dcfsf_varlat)
  54. (rl_varsubstat!* . dcfsf_varsubstat)
  55. (rl_subsumption!* . acfsf_subsumption)
  56. (rl_bnfsimpl!* . cl_bnfsimpl)
  57. (rl_sacat!* .acfsf_sacat)
  58. (rl_sacatlp!* . acfsf_sacatlp)
  59. (rl_fctrat!* . acfsf_fctrat)
  60. (rl_tordp!* . ordp)
  61. (rl_a2cdl!* . acfsf_a2cdl)
  62. (rl_t2cdl!* . acfsf_t2cdl)
  63. (rl_getineq!* . acfsf_getineq)
  64. (rl_structat!* . acfsf_structat)
  65. (rl_ifstructat!* . acfsf_ifstructat)
  66. (rl_termmlat!* . acfsf_termmlat)
  67. (rl_multsurep!* . acfsf_multsurep)
  68. (rl_fbqe!* . cl_fbqe)));
  69. % Switches
  70. put('dcfsf,'rl_cswitches,'(
  71. (rlsusi . nil)
  72. ));
  73. % Services
  74. put('dcfsf,'rl_services,'(
  75. (rl_subfof!* . cl_subfof)
  76. (rl_identifyonoff!* . cl_identifyonoff)
  77. (rl_simpl!* . cl_simpl)
  78. (rl_thsimpl!* . acfsf_thsimpl)
  79. (rl_nnf!* . cl_nnf)
  80. (rl_nnfnot!* . cl_nnfnot)
  81. (rl_pnf!* . cl_pnf)
  82. (rl_cnf!* . acfsf_cnf)
  83. (rl_dnf!* . acfsf_dnf)
  84. (rl_all!* . cl_all)
  85. (rl_ex!* . cl_ex)
  86. (rl_atnum!* . cl_atnum)
  87. (rl_tab!* . cl_tab)
  88. (rl_atab!* . cl_atab)
  89. (rl_itab!* . cl_itab)
  90. (rl_gsc!* . acfsf_gsc)
  91. (rl_gsd!* . acfsf_gsd)
  92. (rl_gsn!* . acfsf_gsn)
  93. (rl_ifacl!* . cl_ifacl)
  94. (rl_ifacml!* . cl_ifacml)
  95. (rl_matrix!* . cl_matrix)
  96. (rl_apnf!* . cl_apnf)
  97. (rl_atml!* . cl_atml)
  98. (rl_tnf!* . cl_tnf)
  99. (rl_atl!* . cl_atl)
  100. (rl_struct!* . cl_struct)
  101. (rl_ifstruct!* . cl_ifstruct)
  102. (rl_termml!* . cl_termml)
  103. (rl_terml!* . cl_terml)
  104. (rl_varl!* . cl_varl)
  105. (rl_fvarl!* . cl_fvarl)
  106. (rl_bvarl!* . cl_bvarl)
  107. (rl_gentheo!* . cl_gentheo)
  108. (rl_decdeg!* . acfsf_decdeg)
  109. (rl_decdeg1!* . acfsf_decdeg1)
  110. (rl_surep!* . cl_surep)
  111. (rl_qe!* . dcfsf_qe)
  112. (rl_qeipo!* . cl_qeipo)
  113. (rl_siaddatl!* . cl_siaddatl)));
  114. % Admin
  115. put('dcfsf,'simpfnname,'dcfsf_simpfn);
  116. put('dcfsf,'simpdefault,'dcfsf_simprel);
  117. put('dcfsf,'rl_prepat,'dcfsf_prepat);
  118. put('dcfsf,'rl_resimpat,'dcfsf_resimpat);
  119. put('dcfsf,'rl_lengthat,'dcfsf_lengthat);
  120. put('dcfsf,'rl_prepterm,'prepf);
  121. put('dcfsf,'rl_simpterm,'dcfsf_simpterm);
  122. algebraic infix equal;
  123. put('equal,'dcfsf_simpfn,'dcfsf_chsimpat);
  124. put('equal,'number!-of!-args,2);
  125. algebraic infix neq;
  126. put('neq,'dcfsf_simpfn,'dcfsf_chsimpat);
  127. put('neq,'number!-of!-args,2);
  128. put('neq,'rtypefn,'quotelog);
  129. newtok '((!< !>) neq);
  130. algebraic infix d;
  131. put('d,'number!-of!-args,2);
  132. put('d,'simpfn,'dcfsf_simpd);
  133. precedence d,**;
  134. flag('(equal neq d),'spaced);
  135. flag('(dcfsf_chsimpat),'full);
  136. procedure dcfsf_simpterm(u);
  137. % Differentially closed field simp term. [u] is Lisp Prefix. Returns
  138. % the [u] as an DCFSF term.
  139. numr simp u;
  140. procedure dcfsf_prepat(f);
  141. % Differentially closed field prep atomic formula. [f] is an DCFSF
  142. % atomic formula. Returns [f] in Lisp prefix form.
  143. {dcfsf_op f,prepf dcfsf_arg2l f,prepf dcfsf_arg2r f};
  144. procedure dcfsf_resimpat(f);
  145. % Differentially closed field resimp atomic formula. [f] is an DCFSF
  146. % atomic formula. Returns the atomic formula [f] with resimplified
  147. % terms.
  148. dcfsf_mk2(dcfsf_op f,
  149. numr resimp !*f2q dcfsf_arg2l f,numr resimp !*f2q dcfsf_arg2r f);
  150. procedure dcfsf_simpd(u);
  151. begin scalar v,n;
  152. if length u neq 2 then
  153. rederr "dcfsf_simpd: d is infix with 2 arguments";
  154. v := car u;
  155. if not idp v then
  156. rederr {"dcfsf_simpd:",v,"is not a variable"};
  157. n := cadr u;
  158. if not (numberp n and n >=0) then
  159. rederr {"dcfsf_simpd:",n,"is not a natural number"};
  160. if eqn(n,0) then
  161. return mksq(v,1);
  162. return mksq('d . u,1)
  163. end;
  164. procedure dcfsf_lengthat(f);
  165. % Differentially closed field length of atomic formula. [f] is an
  166. % atomic formula. Returns a number, the length of [f].
  167. 2;
  168. procedure dcfsf_chsimpat(u);
  169. % Differentially closed field chain simp atomic formula. [u] is the
  170. % Lisp prefix representation of a chain of atomic formulas, i.e.,
  171. % the operators are nested right associatively. Returns a formula,
  172. % which is the corresponding conjunction.
  173. rl_smkn('and,for each x in dcfsf_chsimpat1 u collect dcfsf_simpat x);
  174. procedure dcfsf_chsimpat1(u);
  175. % Differentially closed field chain simp atomic formula. [u] is the
  176. % Lisp prefix representation of a chain of atomic formulas, i.e.,
  177. % the operators are nested right associatively.
  178. begin scalar leftl,rightl,lhs,rhs;
  179. lhs := cadr u;
  180. if pairp lhs and dcfsf_opp car lhs then <<
  181. leftl := dcfsf_chsimpat1 lhs;
  182. lhs := caddr lastcar leftl
  183. >>;
  184. rhs := caddr u;
  185. if pairp rhs and dcfsf_opp car rhs then <<
  186. rightl := dcfsf_chsimpat1 rhs;
  187. rhs := cadr car rightl
  188. >>;
  189. return nconc(leftl,{car u,lhs,rhs} . rightl)
  190. end;
  191. procedure dcfsf_simpat(u);
  192. % Differentially closed field simp atomic formula. [u] is Lisp
  193. % prefix. Returns [u] as an atomic formula.
  194. begin scalar op,lhs,rhs,nlhs,f;
  195. op := car u;
  196. lhs := simp cadr u;
  197. if not (!*rlnzden or (domainp denr lhs)) then
  198. typerr(u,"atomic formula");
  199. rhs := simp caddr u;
  200. if not (!*rlnzden or (domainp denr rhs)) then
  201. typerr(u,"atomic formula");
  202. lhs := subtrsq(lhs,rhs);
  203. nlhs := numr lhs;
  204. if !*rlnzden and not domainp denr lhs then <<
  205. f := dcfsf_0mk2(op,nlhs);
  206. if !*rladdcond then
  207. f := rl_mkn('and,{dcfsf_0mk2('neq,denr lhs),f});
  208. return f
  209. >>;
  210. return dcfsf_0mk2(op,nlhs)
  211. end;
  212. procedure dcfsf_op(atf);
  213. % Differentially closed field operator. [atf] is an atomic formula
  214. % $R(t_1,t_2)$. Returns $R$.
  215. car atf;
  216. procedure dcfsf_arg2l(atf);
  217. % Differentially closed field binary operator left hand side
  218. % argument. [atf] is an atomic formula $R(t_1,t_2)$. Returns $t_1$.
  219. cadr atf;
  220. procedure dcfsf_arg2r(atf);
  221. % Differentially closed field binary operator right hand side
  222. % argument. [atf] is an atomic formula $R(t_1,t_2)$. Returns $t_2$.
  223. caddr atf;
  224. procedure dcfsf_argn(atf);
  225. % Differentially closed field n-ary operator argument list. [atf] is
  226. % an atomic formula $R(t_1,t_2)$. Returns the list $(t_1,t_2)$.
  227. {cadr atf,caddr atf};
  228. procedure dcfsf_mk2(op,lhs,rhs);
  229. % Differentially closed field make atomic formula for binary
  230. % operator. [op] is a relation; [lhs] and [rhs] are terms. Returns
  231. % the atomic formula $[op]([lhs],[rhs])$.
  232. {op,lhs,rhs};
  233. procedure dcfsf_0mk2(op,lhs);
  234. % Differentially closed field make zero right hand side atomic
  235. % formula for binary operator. [op] is a relation [lhs] is a term.
  236. % Returns the atomic formula $[op]([lhs],0)$.
  237. {op,lhs,nil};
  238. procedure dcfsf_mkn(op,argl);
  239. % Differentially closed field make atomic formula for n-ary
  240. % operator. [op] is a relation; [argl] is a list $(t_1,t_2)$ of
  241. % terms. Returns the atomic formula $[op](t_1,t_2)$.
  242. {op,car argl,cadr argl};
  243. procedure dcfsf_opp(op);
  244. % Differentially closed field operator predicate. [op] is an
  245. % S-expression. Returns non-[nil] iff op is a relation.
  246. op memq '(equal neq);
  247. endmodule; % [dcfsf]
  248. end; % of file