This transformation performs finite-differencing, aka incrementalization.
(finite-difference fn term-to-replace rules [:skip-termination bool] ;; Default: nil [:verify-guards t/nil/auto] ;; Default: :auto [:guard-hints hints/:auto] ;; Default: :auto [:new-param-name name] ;; Default: nil [:expand-lets bool] ;; Default: t [:extra-rules rules] ;; Default: nil [:theorem-name name] ;; Default: nil [:build-wrapper bool] ;; Default: t [:theorem-disabled bool] ;; Default: nil [:function-disabled bool] ;; Default: nil [:new-name sym] ;; New name to use for the function (if :auto, the transformation generates a name), Default: :auto [:check-guard bool] ;; Default: nil, whether to check the claimed relationship in the body of the function (may be needed for termination) [:show-only bool] ;; Default: nil )
Consider a function, F(x) [assume F is unary for this discussion], whose body includes some term, T(x), over the parameter x. It may be the case that T could be calculated incrementally (that is, we can use the current value of T(X) to compute the value of T(x) that will be needed on the next iteration, after x is updated). This may be cheaper than calculating T(x) each time.
The transformation does the following: