1 Supported Language
1.1 Grammar
Any expression that when fully expanded conforms to differentiable-expr in the grammar below is amenable to differentiation (with grad and the like). Evaluating the resulting derivative will fail unless:
The expression evaluates to a procedure;
All of its subexpressions expr evaluate to a single value; and
Any procedures called, that are not defined within the expression, are registered as primitives.
differentiable-expr | = | expr | ||||
| | (#%expression expr) | |||||
expr | = | id | ||||
| | (#%plain-lambda formals expr ...+) | |||||
| | (if expr expr expr) | |||||
| | (begin expr ...+) | |||||
| | (begin0 expr expr ...) | |||||
| |
| |||||
| |
| |||||
| | (set! id expr) | |||||
| | (quote datum) | |||||
| | (quote-syntax datum) | |||||
| | (quote-syntax datum #:local) | |||||
| | (#%plain-app expr ...+) | |||||
| | (#%variable-reference id) | |||||
| | (#%variable-reference (#%top . id)) | |||||
| | (#%variable-reference) | |||||
formals | = | (id ...) | ||||
| | (id ...+ . id) | |||||
| | id |
The grammar is a strict subset of that for fully-expanded expressions. The differences are: case-lambda, #%top and with-continuation-mark are not included, and let-values and letrec-values are restricted to binding single values. See also Limitations.
1.2 Primitives
(require rackpropagator/primitives) | |
package: rackpropagator-lib |
This module is required by the rackpropagator module, and all of its exported bindings are re-provided.
The bindings below are registered as primitives when this module is instantiated. Registering a backpropagator does not affect the binding otherwise, so e.g. + below will still bind the regular Racket addition function.
Of these, the following are are not documented elsewhere (they are provided by the rackpropagator module):
procedure
procedure
(vector-fold f z v) → any/c
f : procedure? z : any/c v : vector?
> (vector-fold + 0 #(1 2 3 4 5)) 15