caelum0x 75afe3b0f4 feat(graph): factor distributivity over subtraction in e-graph rewrites
Add a new sound rewrite rule to the equality-saturation simplifier:
`a*b - a*c -> a*(b - c)`, the cost-reducing (7->5 nodes) direction of
distributivity over subtraction. It mirrors the existing `factor_sum`
rule and reuses `as_product`.

Soundness: `a*(b - c) = a*b - a*c` holds for all reals, so the rewrite
is unconditionally value-preserving with no domain caveat. Multiplication
is commutative, so the shared factor is matched in any position; subtraction
is not, so the remainders keep their minuend/subtrahend roles (rest_left
from the left product, rest_right from the right).

- rules.rs: add `factor_difference`, wire into `reduce_subtract`, +3 unit tests
- simplify_soundness.rs: +3 battery entries (shared factor in each position);
  the sampled cross-check now runs 9458 value-agreement checks and stays green
- spec README: document the difference-factoring rule in the rule table

cargo test / build / fmt --check / clippy -D warnings all pass.
2026-08-25 12:26:32 +03:00
..
2026-08-16 20:44:15 +03:00
2026-08-16 20:44:15 +03:00