private Map<Expression, List<ANumber>> selectConstants(List<Expression> evaluated) {
Map<Expression, List<ANumber>> selected = new HashMap(); // ai*c -> a1, a2, ... an
NumberPattern a = new NumberPattern();
TerminationPattern c = new Constant();
ExpressionPattern p = new Multiplication(a, c);
for (Expression e : evaluated) {
if (e.isConstant()) {
if (e instanceof ANumber) { // 1 -> numbers
addToSelectionMap(selected, Naturals.one(), (ANumber) e);
} else if (p.matches(e)) {
addToSelectionMap(selected, c.hit(), a.hit());
} else {
addToSelectionMap(selected, e, Naturals.one());
}
}