crequsol.red 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. %********************************************************************
  2. module equivalence$
  3. %********************************************************************
  4. % Routines for testing equivalence of solutions
  5. % Author: Thomas Wolf
  6. % 1996
  7. algebraic procedure extrfun(sol)$
  8. % unpacking the free functions from the list of free functions
  9. % together with their dependencies
  10. for each f in third sol collect <<
  11. for each h in rest f do depend first f,h;
  12. first f
  13. >>$
  14. algebraic procedure equivsol(sol1,sol2,vl)$
  15. % checking equivalence of two solutions of crack, that have been
  16. % `completed' with the procedure `completesol' before.
  17. % The evaluated functions should have identical names in both
  18. % solutions. None of both solutions should contain any unsolved
  19. % equations.
  20. % vl is a list of all independent variables in both solutions.
  21. begin
  22. scalar f1,f2,s1,s2,ff2,f,h,s,v,mm_,oldtime;
  23. symbolic fluid '(time_);
  24. if (first sol1 neq {}) or
  25. (first sol2 neq {}) or
  26. (length second sol1 neq length second sol2) or
  27. (length third sol1 neq length third sol2) then return nil;
  28. f1:=extrfun(sol1);
  29. f2:=extrfun(sol2);
  30. % substituting the names of free functions in sol2 to avoid
  31. % name clashes
  32. s2:=second sol2;
  33. ff2:=for each f in f2 collect <<
  34. h:=lisp gensym();
  35. s2:=sub(f=h,s2);
  36. s:=fargs(f);
  37. for each v in s do depend h,v;
  38. h
  39. >>;
  40. % conditions of equivalence of both solutions
  41. s1:=for each s in second sol1 collect (lhs s - rhs s);
  42. s1:=sub(s2,s1);
  43. lisp<<oldtime:=time_;time_:=nil>>;
  44. h:=crack(s1,{},f1,vl);
  45. lisp(time_:=oldtime);
  46. % is there a regular relation beetween the free functions
  47. % of sol1 and sol2?
  48. if h={} or (length h neq 1) then return nil
  49. else h:=first h;
  50. if (first h neq {}) or (third h neq {}) then return nil;
  51. s2:=second h;
  52. h:=length f1;
  53. matrix m__(h,h);
  54. for f:=1:h do for s:=1:h do
  55. m__(f,s):=df(rhs part(s2,f),part(ff2,s));
  56. % cleaning dependencies
  57. for each h in ff2 do <<
  58. s:=fargs(h);
  59. for each v in s do nodepend h,v;
  60. >>;
  61. return if det m__=0 then nil
  62. else t
  63. end$
  64. algebraic procedure completesol(sol)$
  65. % substitutes in a list of solutions of crack the list of free or yet
  66. % unevaluated functions by a list of lists containing each function
  67. % and the variables they depend on. This is useful to save solutions
  68. % in files.
  69. list(first sol,
  70. second sol,
  71. for each f in third sol collect cons(f,fargs f),
  72. if length sol>3 then part(sol,4)
  73. else {}
  74. )$
  75. endmodule$
  76. end$