/** This implements a "collect" function as transformation rules. It collects terms of x with like exponents. */ transformations collect { collect[(_a:1) _x^(_n:1) + (_b:1) _x^(_n) + (_c:0) , _x] <-> collect[(_a + _b) _x^_n + _c, _x] collect[_a === _d, _x] <-> collect[_a, _x] === collect[_d, _x] // Bailout condition collect[_a, _x] :: freeOf[_a, _x] <-> _a }