Hi,

Are there any libraries for manipulating algebraic expression trees?

In particular, take an expression tree and simplify it down.

I'm working up the next release of PyGene, the genetic programming and

genetic algorithms library.

Part of PyGene works with trees holding algebraic expressions. For

example, the expression:

f = x**2 + sqrt(y) + 7

is represented as the tree:

+

**

x

2

+

sqrt

y

7

My GP code is successfully evolving expression trees to solve problems,

however they're often full of redundancies, eg adding y in one part then

subtracting y later on.

I've added some simplification code which takes out some of the more

obvious redundancies - eg replacing 'x - x' with '0', and replacing

'y / 1' with 'y' etc. But there'd be a pile of work to make this code

smart enough to go deep into the tree and fix everything.

So if someone can point me in the direction of an algebraic expressions

library that can simplify expression trees and weed out redundancies, that

would be awesome.

Many thanks if you can help.

Cheers

David