7 Computer Algebra Services
| (require animate/math/cas) | package: animate |
struct
(struct cas-service (name version capabilities query) #:transparent) name : symbol? version : any/c capabilities : (listof symbol?) query : procedure?
struct
(struct cas-result (status value evidence diagnostics) #:transparent) status : (or/c 'ok 'unknown 'unsupported 'unavailable 'timeout 'error) value : any/c evidence : (or/c verification? #f) diagnostics : (listof string?)
procedure
(math-services [ #:local local #:extended extended]) → math-services? local : (or/c cas-service? #f) = #f extended : (or/c cas-service? #f) = #f
The local and extended descriptors are optional; false disables that position. Construction does not execute a service callback. Local lookup order is preserved before the extended service.
procedure
(math-services? value) → boolean?
value : any/c
procedure
(math-services-local record) → (or/c cas-service? #f)
record : math-services?
This accessor is pure. It does not copy, reorder, render, or mutate the record.
procedure
(math-services-extended record) → (or/c cas-service? #f)
record : math-services?
This accessor is pure. It does not copy, reorder, render, or mutate the record.
procedure
(cas-query! service capability payload context [ #:timeout timeout]) → cas-result? service : cas-service? capability : symbol? payload : any/c context : math-context? timeout : (and/c real? positive?) = 10
The capability must be declared by the service. The callback receives capability, payload, and mathematical context and must return one cas-result. The positive finite timeout is in seconds and applies to this individual call. A custodian terminates the owned thread on completion or timeout. This is a resource boundary, not a security sandbox. Exceptions, invalid callback results, evidence for another proposition, and decisions attached to failed statuses become explicit error results.
procedure
(cas-calculate! service operation datum [ #:context context #:timeout timeout]) → cas-result? service : cas-service? operation : symbol? datum : math-datum? context : math-context? = (math-context) timeout : (and/c real? positive?) = 10
Packages (list operation datum) as a calculate query. The result value is a proposed calculation result, never an invented pedagogical trace.
procedure
(verify-derivation! d [ #:services backends #:timeout timeout]) → verification? d : (or/c derivation? case-derivation?) backends : math-services? = (math-services) timeout : (and/c real? positive?) = 10
Rechecks recorded unresolved obligations and returns new evidence. It does not mutate or retroactively relabel the original derivation. Case coverage records remain explicit. The timeout is per backend call, not a whole-derivation deadline.
procedure
(verify-proposition! proposition context [ #:services backends #:timeout timeout]) → verification? proposition : math-datum? context : math-context? backends : math-services? = (math-services) timeout : (and/c real? positive?) = 10
Checks local definedness first, then queries configured services when needed. Only successful matching evidence can supply a decision. Conflicting established/refuted service reports remain unknown; no backend silently wins.
procedure
(call-with-math-services! backends thunk [ #:timeout timeout]) → any backends : math-services? thunk : procedure? timeout : (and/c real? positive?) = 10
Installs an explicit construction-time prover around a zero-argument thunk. The thunk may trigger bounded CAS calls while constructing mathematics. The service callbacks are not retained in the resulting animation scene.