Wrote rewriter to generate all possible rewrites.