boundlab.diff.expr.lift_diff#

boundlab.diff.expr.lift_diff(value)[source]#

Fold the shared part of a mixed sum into its differential component.

Adding a plain expression or constant to a differential one goes through the base Expr.__add__(), which places unlike addends side by side in an ExprGroup. Anything grouped next to a differential component was contributed identically to both networks, so this lift adds it to both branches — where it cancels in the difference — and folds an absorbed pair in with diff += pair.x − pair.y. Values without a differential component pass through untouched.