acfsfmisc.red 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  1. % ----------------------------------------------------------------------
  2. % $Id: acfsfmisc.red,v 1.7 1999/04/13 13:05:33 sturm Exp $
  3. % ----------------------------------------------------------------------
  4. % Copyright (c) 1995-1999 Andreas Dolzmann and Thomas Sturm
  5. % ----------------------------------------------------------------------
  6. % $Log: acfsfmisc.red,v $
  7. % Revision 1.7 1999/04/13 13:05:33 sturm
  8. % Minor corrections in comments.
  9. %
  10. % Revision 1.6 1999/04/12 09:25:48 sturm
  11. % Removed procedure acfsf_canegrel and acfsf_anegrel.
  12. % Updated comments for exported procedures.
  13. %
  14. % Revision 1.5 1999/04/01 11:27:16 dolzmann
  15. % Added comment for acfsf_structat.
  16. %
  17. % Revision 1.4 1999/03/23 08:19:21 dolzmann
  18. % Changed copyright information.
  19. % Added fluids for the rcsid of the file and for the copyright information.
  20. %
  21. % Revision 1.3 1999/03/21 13:40:39 dolzmann
  22. % Added procedure acfsf_canegrel and acfsf_anegrel which were commented out.
  23. %
  24. % Revision 1.2 1997/08/24 16:18:40 sturm
  25. % Added service rl_surep with black box rl_multsurep.
  26. % Added service rl_siaddatl.
  27. %
  28. % Revision 1.1 1997/08/22 17:30:40 sturm
  29. % Created an acfsf context based on ofsf.
  30. %
  31. % ----------------------------------------------------------------------
  32. lisp <<
  33. fluid '(acfsf_misc_rcsid!* acfsf_misc_copyright!*);
  34. acfsf_misc_rcsid!* :=
  35. "$Id: acfsfmisc.red,v 1.7 1999/04/13 13:05:33 sturm Exp $";
  36. acfsf_misc_copyright!* := "Copyright (c) 1995-1999 A. Dolzmann and T. Sturm"
  37. >>;
  38. module acfsfmisc;
  39. % Algebraically closed field standard form other. Submodule of [acfsf].
  40. procedure acfsf_termprint(u);
  41. % Algebraically closed field term print. [u] is a
  42. % term. The return value is not specified. Prints [u] AM-like.
  43. <<
  44. sqprint !*f2q u where !*nat=nil;
  45. ioto_prin2 nil
  46. >>;
  47. procedure acfsf_clnegrel(r,flg);
  48. % Algebraically closed field conditionally logically negate
  49. % relation. [r] is a relation. Returns for [flg] equal to [nil] a
  50. % relation $R$ such that for terms $t_1$, $t_2$ we have
  51. % $R(t_1,t_2)$ equivalent to $\lnot [r](t_1,t_2)$. Returns [r] for
  52. % non-[nil] [flg].
  53. if flg then r else acfsf_lnegrel r;
  54. procedure acfsf_lnegrel(r);
  55. % Algebraically closed field logically negate relation. [r] is a
  56. % relation. Returns a relation $R$ such that for terms $t_1$, $t_2$
  57. % we have $R(t_1,t_2)$ equivalent to $\lnot [r](t_1,t_2)$.
  58. if r eq 'equal then 'neq
  59. else if r eq 'neq then 'equal
  60. else rederr {"acfsf_lnegrel: unknown operator ",r};
  61. procedure acfsf_fctrat(atf);
  62. % Algebraically closed field factorize atomic formula. [atf] is an
  63. % atomic formula. Returns the factorized left hand side of [atf] as
  64. % a list $(...,(f_i . n_i),...)$, where the $f_i$ are the factors
  65. % as SF's and the $n_i$ are the corresponding multiplicities. The
  66. % integer content is dropped.
  67. cdr fctrf acfsf_arg2l atf;
  68. procedure acfsf_negateat(f);
  69. % Algebraically closed field negate atomic formula. [f] is an
  70. % atomic formula. Returns an atomic formula equivalent to $\lnot
  71. % [f]$.
  72. acfsf_mkn(acfsf_lnegrel acfsf_op f,acfsf_argn f);
  73. procedure acfsf_varlat(atform);
  74. % Algebraically closed field variable list of atomic formula.
  75. % [atform] is an atomic formula. Returns the set of variables
  76. % contained in [atform] as a list.
  77. kernels acfsf_arg2l(atform);
  78. procedure acfsf_varsubstat(atf,new,old);
  79. % Algebraically closed substitute variable for variable in atomic
  80. % formula. [atf] is an atomic formula; [new] and [old] are
  81. % variables. Returns [atf] with [new] substituted for [old].
  82. acfsf_0mk2(acfsf_op atf,numr subf(acfsf_arg2l atf,{old . new}));
  83. procedure acfsf_ordatp(a1,a2);
  84. % Algebraically closed field order predicate for atomic formulas.
  85. % [a1] and [a2] are atomic formulas. Returns [T] iff [a1] is
  86. % strictly less than [a2] wrt. some syntactical ordering; returns
  87. % [nil] else. The specification that [nil] is returned if
  88. % $[a1]=[a2]$ is used in [acfsf_subsumeandcut].
  89. begin scalar lhs1,lhs2;
  90. lhs1 := acfsf_arg2l a1;
  91. lhs2 := acfsf_arg2l a2;
  92. if lhs1 neq lhs2 then return ordp(lhs1,lhs2);
  93. return acfsf_ordrelp(acfsf_op a1,acfsf_op a2)
  94. end;
  95. procedure acfsf_ordrelp(r1,r2);
  96. % Algebraically closed field standard form relation order
  97. % predicate. [r1] and [r2] are acfsf-relations. Returns a [T] iff
  98. % $[r1] <= [r2]$.
  99. r1 eq r2 or r1 eq 'equal;
  100. procedure acfsf_a2cdl(atml);
  101. % Algebraically closed field atomic formulas to case distinction
  102. % lists. [atml] is a multiplicity list of atomic formulas. Returns
  103. % a list $(...,(t_i = 0, t_i \neq 0),...)$ of case distinctions
  104. % lists, where the $t_i$ are the right hand side terms of the
  105. % atomic formulas in [atml].
  106. begin scalar x;
  107. return for each pr in atml collect <<
  108. x := acfsf_arg2l car pr;
  109. {acfsf_0mk2('equal,x),acfsf_0mk2('neq,x)}
  110. >>
  111. end;
  112. procedure acfsf_t2cdl(term);
  113. % Algebraically closed field term to case distinction list. [term]
  114. % is a term. Returns a case distinction list $([term] = 0, [term]
  115. % \neq 0)$ wrt. [term].
  116. {acfsf_0mk2('equal,term),acfsf_0mk2('neq,term)};
  117. procedure acfsf_subat(al,f);
  118. % Algebraically closed field substitute into atomic formula. [al]
  119. % is an ALIST $(..., (v_i . t_i), ...)$, where the $v_i$ are
  120. % kernels, and the $t_i$ are Lisp prefix terms; [f] is an atomic
  121. % formula. Returns [f] with $t_i$ substituted for each occurrence
  122. % of $v_i$. The $t_i$ must be such that the substitution does not
  123. % yield parametric denominators.
  124. begin scalar nlhs;
  125. nlhs := subf(acfsf_arg2l f,al);
  126. if not domainp denr nlhs then
  127. rederr "parametric denominator after substitution";
  128. return acfsf_0mk2(acfsf_op f,numr nlhs)
  129. end;
  130. procedure acfsf_subalchk(al);
  131. % Algebraically closed field substitution ALIST check. [al] is an
  132. % ALIST $(..., (v_i . t_i), ...)$, where the $v_i$ are kernels, and
  133. % the $t_i$ are Lisp prefix terms. The return value is unspecified.
  134. % Raises an error if some $t_i$ contains a parametric denominator.
  135. for each x in al do
  136. if not domainp denr simp cdr x then
  137. rederr "parametric denominator in substituted term";
  138. procedure acfsf_eqnrhskernels(x);
  139. % Algebraically closed field equation right hand side kernels. [x]
  140. % is an equation. Returns the set of kernels contained in the right
  141. % hand side of [x] as a list.
  142. nconc(kernels numr w,kernels denr w) where w=simp cdr x;
  143. procedure acfsf_getineq(f,bvl);
  144. % Algebraically closed field generate theory get inequalities. [f]
  145. % is a formula; [bvl] is a list of variables. Returns the list of
  146. % all inequalities occuring in [f] that do not contain any of the
  147. % variables in [bvl].
  148. begin scalar atml,atf,cdl;
  149. atml := cl_atml f;
  150. while atml do <<
  151. atf := caar atml;
  152. atml := cdr atml;
  153. if acfsf_op atf eq 'neq and
  154. null intersection(bvl, kernels acfsf_arg2l atf) then
  155. cdl := atf . cdl
  156. >>;
  157. return cdl
  158. end;
  159. procedure acfsf_structat(at,al);
  160. % Algebraically closed field structure of an atomic formula. [at]
  161. % is an atomic formula $R(t,0)$; [al] is an ALIST. Returns an
  162. % atomic formula. [al] is of the form $(..., (t_i . v_i), ...)$,
  163. % where the $t_i$ are SF's and the $v_i$ are variables. The left
  164. % hand side $t$ of [at] matches one of the $t_i$ in [al]. Returns
  165. % the atomic formula $R(v_i,0)$.
  166. begin scalar lhs;
  167. lhs := acfsf_arg2l at;
  168. if domainp lhs then
  169. return at;
  170. return acfsf_0mk2(acfsf_op at, numr simp cdr assoc(lhs,al))
  171. end;
  172. procedure acfsf_ifstructat(at,al);
  173. % Algebraically closed field irreducible factor structure of an
  174. % atomic formula. [at] is an atomic formula $R(t,0)$ where $t = c
  175. % ... s_j ...$ is a factorization of $t$ into irreducible factors;
  176. % [al] is an ALIST. Returns an atomic formula. [al] is of the form
  177. % $(..., (t_i . v_i), ...)$, where the $t_i$ are SF's and the $v_i$
  178. % are variables. Each factor $s_j$ of the left hand side $t$ of
  179. % [at] matches one of the $t_i$ in [al]. Returns the atomic formula
  180. % $R(c ... v_i ..., 0)$.
  181. begin scalar w,r;
  182. w := fctrf acfsf_arg2l at;
  183. r := car w;
  184. for each x in cdr w do
  185. r := multf(r,expf(numr simp cdr assoc(car x,al),cdr x));
  186. return acfsf_0mk2(acfsf_op at,r)
  187. end;
  188. procedure acfsf_termmlat(at);
  189. % Algebraically closed field term multiplicity list of atomic
  190. % formula. [at] is an atomic formula. Returns the multiplicity list
  191. % of all non-zero terms in [at].
  192. if acfsf_arg2l at then
  193. {(acfsf_arg2l at . 1)};
  194. procedure acfsf_decdeg(f);
  195. % Algebraically closed field decrease degrees. [f] is a formula.
  196. % Returns a formula equivalent to [f], hopefully decreasing the
  197. % degrees of the bound variables.
  198. acfsf_decdeg0 cl_rename!-vars f;
  199. procedure acfsf_decdeg0(f);
  200. begin scalar op,w,gamma,newmat;
  201. op := rl_op f;
  202. if rl_boolp op then
  203. return rl_mkn(op,for each subf in rl_argn f collect
  204. acfsf_decdeg0 subf);
  205. if rl_quap op then
  206. return rl_mkq(op,rl_var f,
  207. car acfsf_decdeg1(acfsf_decdeg0 rl_mat f,{rl_var f}));
  208. % [f] is not complex.
  209. return f
  210. end;
  211. procedure acfsf_decdeg1(f,vl);
  212. % Algebraically closed field decrease degrees. [f] is a formula;
  213. % [vl] is either a list of variables $v$ that do not occur boundly
  214. % in [f], or the identifier [fvarl]. Returns a pair $(\phi . l)$;
  215. % $l$ is a list of pairs $(..., (v_i . d_i), ...)$, with $v_i \in
  216. % [vl]$ and integer $d_i$; $\phi$ is obtained from [f] by replacing
  217. % powers $v_i^{d_i}$ by $v_i$. We have $\exists [vl] ([f])$
  218. % equivalent to $\exists [vl] (\phi)$. [fvarl] selects the list of
  219. % all free variables in [f] as [vl].
  220. begin scalar dvl; integer n;
  221. if vl eq 'fvarl then
  222. vl := cl_fvarl1 f;
  223. for each v in vl do <<
  224. n := acfsf_decdeg2(f,v);
  225. if n>1 then <<
  226. f := acfsf_decdeg3(f,v,n);
  227. dvl := (v . n) . dvl
  228. >>
  229. >>;
  230. return f . dvl
  231. end;
  232. procedure acfsf_decdeg2(f,v);
  233. % Algebraically closed field standard form decrement degree
  234. % subroutine. [f] is a formula; [v] is a variable. Returns an
  235. % INTEGER $n$. The degree of [v] in [f] can be decremented using
  236. % the substitution $[v]^n=v$.
  237. begin scalar a,w,atl,dgcd,!*gcd,oddp;
  238. !*gcd := T;
  239. atl := cl_atl1 f;
  240. dgcd := 0;
  241. while atl and dgcd neq 1 do <<
  242. a := car atl;
  243. atl := cdr atl;
  244. w := acfsf_ignshift(a,v);
  245. if null w then << % [w neq 'ignore]
  246. a := sfto_reorder(acfsf_arg2l a,v);
  247. while (not domainp a) and (mvar a eq v) and dgcd neq 1 do <<
  248. dgcd := gcdf(dgcd,ldeg a);
  249. a := red a
  250. >>
  251. >>
  252. >>;
  253. if dgcd = 0 then
  254. return 1;
  255. return dgcd
  256. end;
  257. procedure acfsf_ignshift(at,v);
  258. % Orderd field standard form ignore shift. [at] is an atomic
  259. % formula; [v] is a variable. Returns [nil] or ['ignore].
  260. begin scalar w;
  261. w := sfto_reorder(acfsf_arg2l at,v);
  262. if not domainp w and null red w and mvar w eq v then
  263. return 'ignore
  264. end;
  265. procedure acfsf_decdeg3(f,v,n);
  266. % Algebraically closed field standard form decrement degree. [f] is
  267. % a formula; [v] is a variable; [n] is an integer. Returns a
  268. % formula.
  269. cl_apply2ats1(f,'acfsf_decdegat,{v,n});
  270. procedure acfsf_decdegat(atf,v,n);
  271. % Algebraically closed field standard form decrement degree atomic
  272. % formula. [f] is an atomic formula; [v] is a variable; [n] is an
  273. % integer. Returns an atomic formula.
  274. if acfsf_ignshift(atf,v) then
  275. atf
  276. else
  277. acfsf_0mk2(acfsf_op atf,sfto_decdegf(acfsf_arg2l atf,v,n));
  278. procedure acfsf_multsurep(at,atl);
  279. % Algebraically closed field multplicative sure predicate. [at] is
  280. % an atomic formula; [atl] is a theory. Tries to prove [at] wrt.
  281. % [atl]. Returns non-[nil] in case of success.
  282. if acfsf_op at eq 'equal then
  283. acfsf_multsurep!-equal(at,atl)
  284. else
  285. acfsf_multsurep!-neq(at,atl);
  286. procedure acfsf_multsurep!-equal(at,atl);
  287. begin scalar c,a;
  288. c := acfsf_arg2l at;
  289. while atl do <<
  290. a := car atl;
  291. atl := cdr atl;
  292. if acfsf_op a eq 'equal and quotf(c,acfsf_arg2l a) then <<
  293. a := 'found;
  294. atl := nil
  295. >>
  296. >>;
  297. return a eq 'found
  298. end;
  299. procedure acfsf_multsurep!-neq(at,atl);
  300. begin scalar c,a;
  301. c := acfsf_arg2l at;
  302. while atl do <<
  303. a := car atl;
  304. atl := cdr atl;
  305. if acfsf_op a eq 'neq and quotf(acfsf_arg2l a,c) then <<
  306. a := 'found;
  307. atl := nil
  308. >>
  309. >>;
  310. return a eq 'found
  311. end;
  312. endmodule; % [acfsfmisc]
  313. end; % of file