From: Robert D. <rob...@gm...> - 2018-05-13 01:36:12
|
On 2018-05-09, Robert Dodier <rob...@gm...> wrote: > I've made some progress on operator simplifications. The goal is to > make it possible for a user to declare a property analogous to > symmetric, antisymmetric, additive, etc. I've gotten this stuff working well enough to commit it (commit ac31578). I've pasted the Texinfo text below; commit has the rest of the details. Here's the commit message for your enjoyment. $ git log -1 commit ac3157852fc64f0aaaa46c35457ad149469872ed Author: Robert Dodier <rob...@us...> Date: Sat May 12 18:20:39 2018 -0700 New function define_opproperty to define an operator simplification, similar to symmetric, antisymmetric, etc. This implementation has at least two weaknesses, namely (1) once an operator property is defined, there is no way to undo it; (2) Maxima functions can be attached to an operator property to carry out simplification, but Maxima functions are susceptible to kill(functions) or kill(all), which can therefore have an unintended effect of disabling the operator property simplification. Despite these limitations, I believe define_opproperty is usable. See share/multiadditive/bilinear.mac for an example and share/multiadditive/rtest_opproperties.mac for some test cases. Hope this helps, Robert Dodier PS. -- Function: define_opproperty (<property_name>, <simplifier_fn>) Declares the symbol <property_name> to be an operator property, which is simplified by <simplifier_fn>, which may be the name of a Maxima or Lisp function or a lambda expression. After 'define_opproperty' is called, functions and operators may be declared to have the <property_name> property, and <simplifier_fn> is called to simplify them. <simplifier_fn> must be a function of one argument, which is an expression in which the main operator is declared to have the <property_name> property. <simplifier_fn> is called with the global flag 'simp' disabled. Therefore <simplifier_fn> must be able to carry out its simplification without making use of the general simplifier. 'define_opproperty' appends <property_name> to the global list 'opproperties'. 'define_opproperty' returns 'done'. Example: Declare a new property, 'identity', which is simplified by 'simplify_identity'. Declare that 'f' and 'g' have the new property. (%i1) define_opproperty (identity, simplify_identity); (%o1) done (%i2) simplify_identity(e) := first(e); (%o2) simplify_identity(e) := first(e) (%i3) declare ([f, g], identity); (%o3) done (%i4) f(10 + t); (%o4) t + 10 (%i5) g(3*u) - f(2*u); (%o5) u |