&& denominator.matches(d);
} else if (expr instanceof Division) {
return numerator.matches(((Division) expr).lhs())
&& denominator.matches(((Division) expr).rhs());
} else if (expr instanceof Multiplication) {
Multiplication m = (Multiplication) expr;
if (matches(m.lhs())) { // a/b * c -> ac/b
return numerator.matches(new Multiplication(numerator.hit(), m.rhs()));
} else if (matches(m.rhs())) { // a * b/c -> ab/c
return numerator.matches(new Multiplication(m.lhs(), numerator.hit()));
}
}
return false;
}