On this page:
cas-service
cas-result
math-services
math-services?
math-services-local
math-services-extended
cas-query!
cas-calculate!
verify-derivation!
verify-proposition!
call-with-math-services!

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?
A validated service descriptor. The name identifies the provider, version is copied acyclic metadata, and capability order is retained. Version metadata may contain ordinary data containers, but not procedures, cycles, or opaque native resources. The callback must accept three positional arguments and require no keyword arguments. It is executed only through an explicit query boundary. The descriptor is immutable, but the external callback may perform effects and must not be stored in scene state.

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?)
A validated external-service response. The value may be opaque backend data; it is not inserted into a mathematical state automatically. Evidence is optional, and diagnostics are copied into immutable strings in significant order. A failed status cannot supply an established or refuted decision at the query boundary. Verification reports copy the status, evidence, and diagnostics only; the opaque value is not retained inside the mathematical evidence.

procedure

(math-services [#:local local    
  #:extended extended]) → math-services?
  local : (or/c cas-service? #f) = #f
  extended : (or/c cas-service? #f) = #f
Collects optional local and extended service descriptors without executing them.

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
Recognizes a pair of configured CAS service descriptors.

procedure

(math-services-local record) → (or/c cas-service? #f)

  record : math-services?
Returns the configured service without loading its backend.

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?
Returns the configured service without loading its backend.

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
Runs one bounded backend query and shuts down its custodian after every outcome.

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
Requests a backend calculation without changing held presentation syntax.

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 pending obligations without mutating the recorded derivation or its evidence.

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 definedness and queries explicit CAS services without silently resolving disagreements.

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 explicit CAS services only for the dynamic extent of one construction callback.

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.