OKlibrary  0.2.1.6
Auxiliary.mac
Go to the documentation of this file.
```00001 /* Oliver Kullmann, 23.1.2010 (Swansea) */
00002 /* Copyright 2010, 2011, 2012 Oliver Kullmann
00003 This file is part of the OKlibrary. OKlibrary is free software; you can redistribute
00004 it and/or modify it under the terms of the GNU General Public License as published by
00005 the Free Software Foundation and included in this library; either version 3 of the
00006 License, or any later version. */
00007
00022 oklib_include("OKlib/ComputerAlgebra/DataStructures/Lisp/Lists.mac")\$
00023
00024
00025 /* ***********************
00026    * Properties of terms *
00027    ***********************
00028 */
00029
00030 /* Testing whether term p contains some element in CRE-form: */
00031 tcre_p(p) := not is(totaldisrep(p)=p)\$
00032
00033
00034 /* ***************************
00035    * Simplification of terms *
00036    ***************************
00037 */
00038
00039 /* Helper-function for simplification of "simple" terms: */
00040 simplify_st(t) := block([simp:true, simpsum:true],
00042 /* Equality between simple terms: */
00043 simplify_eq(t1,t2) := is(equal(simplify_st(t1-t2), 0))\$
00044 /* Equality between lists (prerequisite: L1 is a list): */
00045 simplify_eql(L1,L2) :=
00046  if not listp(L2) or length(L1)#length(L2) then false else
00047  every_s(lambda([p], simplify_eq(first(p),second(p))), map("[",L1,L2))\$
00048
00049
00050 /* Simplification of arbitrary terms t: */
00051 simplify_t(t) := if atom(t) then t
00052  elseif op(t) = "=" then
00053    if listp(first(t)) then simplify_eql(first(t),second(t))
00054    elseif listp(second(t)) then false
00055    elseif {setp(first(t)),setp(second(t))} = {true,false} then false
00056    else simplify_eq(first(t),second(t))
00057  else simplify_st(t)\$
00058
00059
```