[Aldor-l] Functions and Expression trees

Ralf Hemmecke ralf at hemmecke.de
Thu May 11 06:59:25 EDT 2006


Dear Stephen,

Your suggestion is quite nice, but it does not really solve everything.
If we have

Pkg(R: Ring): with {f: R -> Boolean} == ....

then, of course,

(f$Pkg(SomeExpressionType))(someExpression)

would return a Boolean value and not an expression. And I guess,

Something like

someExpression: SomeExpressionType := "(+ 1 (- 1))"
zero?(someExpression);

will probably return true or false, depending on the simplification that 
is inherent to the SomeExpressionType domain. (The function zero? must 
have been implemented in SomeExpressionType, after all.)

However, the good thing is, one can explicitly tell which 
simplifications are allowed by choosing the right Expression domain.

Ralf



On 05/06/2006 12:18 PM, Stephen Watt wrote:
> There is one partial solution that does not involve inspecting the code:
> 
> If the function is generic, say over a Ring, then you can build the 
> expression tree by running the function instantiated over the expression type.
> E.g.  If the function is exported by Package1(R), then 
> Package1(SomeExpressionType)  will have the + and * operations from 
> SomeExpressionType, so f(symbol1, symbol2) will build the tree you want.
> 
> -- Stephen
> 
> On Sat, May 06, 2006 at 07:36:26AM +0200, Christian Aistleitner wrote:
>> Hello,
>>
>>> my current work involves converting aldor objects to and from OpenMath
>>> format, via. the ExpressionTree type (from the algebra lib.). I'm a bit
>>> stuck when it comes to function objects, I don't seem to be able to get a
>>> handle on anything, the signatures of the functions or the body of the
>>> function.
>>>
>>> It would be really nice to have an extree(f) function [...]
>> I am not convinced that I understood, what you are looking for, but I
>> assume, you want a function extree, such that extree(f) with
>> f( a: Integer, b: Integer ) == { a + 4*b + a*b; }
>> gives you the expression tree
>> ( + a ( * 4 b ) ( * a b ) )
>> .
>>
>> Honestly, I do not know of a way to do this. And I do not think, there is
>> a way to implement such a function. Such a function would require that the
>> Aldor code would know by itself, what it is doing.
>>
>>
>> However, there may be two starting points to look for information:
>>
>> - Aldor's Trace package allows to print the name of a domain (including
>> its parameters).
>> - Given the identifier f of the previously defined function, it is
>> possible to obtain a pointer to a string "f" -- with a lot of trickery,
>> debugging turned on and assuming, you are allowed to call the function to
>> get its name. I could detail on that, if it would be helpful for you.
>>
>>
>> --
>> Kind regards,
>> Christian



More information about the Aldor-l mailing list