edsequiv.red 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. module edsequiv;
  2. % Check if EDS structures are equivalent
  3. % Author: David Hartley
  4. fluid '(xtruncate!*);
  5. infix equiv;
  6. precedence equiv,equal;
  7. symbolic operator equiv;
  8. symbolic procedure equiv(u,v);
  9. if cfrmp u then cfrmp v and equalcfrm(u,v)
  10. else if edsp u then edsp v and edscall equaleds(u,v)
  11. else rerror(eds,000,"Don't know how to test equivalence");
  12. symbolic procedure equalcfrm(m,n);
  13. % m,n:cfrm -> equalcfrm:bool
  14. equall(cfrm_cob m,cfrm_cob n) and
  15. equall(cfrm_crd m,cfrm_crd n) and
  16. equaldrv(cfrm_drv m,cfrm_drv n) and
  17. equalrsx(cfrm_rsx m,cfrm_rsx n);
  18. symbolic procedure equall(u,v);
  19. % u,v:list -> equall:bool
  20. (length u = length v) and subsetp(u,v);
  21. symbolic procedure equaldrv(d1,d2);
  22. % d1,d2:drv -> equaldrv:bool
  23. equall(d1,d2) or
  24. equall(foreach r in d1 collect cadr r,
  25. foreach r in d2 collect cadr r) and
  26. equall(foreach r in d1 collect resimp simp!* caddr r,
  27. foreach r in d2 collect resimp simp!* caddr r);
  28. symbolic procedure equalrsx(r1,r2);
  29. % r1,r2:rsx -> equalrsx:bool
  30. equall(r1,r2) or
  31. equall(foreach r in r1 collect absf numr simp!* r,
  32. foreach r in r2 collect absf numr simp!* r);
  33. symbolic procedure equaleds(s1,s2);
  34. % s1,s2:eds -> equaleds:bool
  35. equalcfrm(eds_cfrm s1,eds_cfrm s2) and
  36. equivsys(eds_sys s1,eds_sys s2) and
  37. equivsys(eds_ind s1,eds_ind s2);
  38. symbolic procedure equivsys(p,q);
  39. % p,q:sys -> equivsys:bool
  40. % Assumes background coframing set up correctly.
  41. equall(p := xreordersys p,q := xreordersys q) or
  42. begin scalar p1,q1,g,xtruncate!*; integer d;
  43. p1 := foreach f in setdiff(p,q) join
  44. if f := xreduce(f,q) then {f};
  45. q1 := foreach f in setdiff(q,p) join
  46. if f := xreduce(f,p) then {f};
  47. if null p1 and null q1 then return t;
  48. if scalarpart p1 or scalarpart q1 then
  49. rerror(eds,000,"Can't compare systems with 0-forms");
  50. if p1 then
  51. << d := 0; foreach f in p1 do d := max(d,degreepf f);
  52. xtruncate!* := d; g := xidealpf q;
  53. p1 := foreach f in p1 join
  54. if f := xreduce(f,g) then {f}>>;
  55. if p1 then return nil;
  56. if q1 then
  57. << d := 0; foreach f in q1 do d := max(d,degreepf f);
  58. xtruncate!* := d; g := xidealpf p;
  59. q1 := foreach f in q1 join
  60. if f := xreduce(f,g) then {f}>>;
  61. return null q1;
  62. end;
  63. endmodule;
  64. end;