Finite differencing can be especially useful in optimizing set
operations.
Consider the following expression that is used in solving the
``k queens'' problem:
* i &isin range(part_sol) &and i &isin { 1 .. k } *
This can be transformed to:
* i &isin setdiff( { 1 .. k } , part_sol ) *

A variable * unoccupied_rows * can be introduced for this expression.
Its initial value is the set * { 1 .. k } *.

An update to * part_sol * (by recursive call),
* part_sol = append( part_sol , i) *
leads to a corresponding change to * unoccupied_rows *
* unoccupied_rows = unoccupied_rows - {i} *
This incremental update may be much cheaper than doing the original
range computation or set difference every time.