On this page:
5.1 Held states and occurrence identity
math
math?
math-datum
math-id
math-context-of
math-occurrences
math-revision
math-with-context
math-occurrence-at
math-inspect
math-datum?
held-substitute
free-of?
datum-ref
datum-paths
occurrence?
occurrence-id
occurrence-path
occurrence-datum
exn:  fail:  math?
exn:  fail:  math-code
exn:  fail:  math-details
current-math-validation
current-math-prover
5.2 Contexts and evidence
math-context
math-context?
math-context-real
math-context-assumptions
math-context-definitions
math-context-restrictions
context-assume
context-add-restrictions
context-expand
context-prove
context-signs
context-real?
context-inconsistent?
context-facts
check-case-coverage
verification?
verification-status
verification-method
verification-proposition
verification-obligations
verification-message
verification-details
established
unknown
refuted
merge-verifications
5.3 Selectors
whole
lhs
rhs
numerator
denominator
at-path
matching
all-matching
operator-of
selector?
resolve-selector
resolve-one
math-select
5.4 Operations and template rules
math-operation?
math-operation-name
math-operation-selector
apply-math-operation
both-sides
cancel-addends
cancel-factor
remove-unit
reduce-identities
evaluate
rewrite-to
reorder-addends
zero-product
square-solutions
abbreviate
each-branch
substitute
conclude
assert-step
define-math-rule
make-math-rule
math-rule?
math-rule-name
use-rule
apply-rule
apply-rewrite
template-bindings
5.5 Derivations and branches
steps
steps/  proc
step-sequence?
derivation-tree
derivation-node?
derivation-node-path
derivation-node-before
derivation-node-after
derivation-node-children
derivation-node-step
derivation-node-at
derivation-node-relation
derivation-node-verification
derivation-step-paths
derive
derive/  proc
derive-cases
make-case-derivation
derivation?
derivation-initial
derivation-steps
derivation-final
case-branch?
case-branch-name
case-branch-guard
case-branch-derivation
case-derivation?
case-derivation-prefix
case-derivation-branches
case-derivation-coverage
solution-check?
solution-check-problem
solution-check-variable
solution-check-value
solution-check-derivation
solution-check-verification
after
derivation-step
derivation-states
derivation-verification
check-solution
rewrite-step?
rewrite-step-name
rewrite-step-before
rewrite-step-after
rewrite-step-rule
rewrite-step-focus
rewrite-step-bindings
rewrite-step-links
rewrite-step-trace
rewrite-step-relation
rewrite-step-verification
rewrite-step-details
rewrite-step-version
trace-descendants
path-link?
path-link-source
path-link-target
path-link-kind
path-link-subtree?
trace-relation?
trace-relation-kind
trace-relation-sources
trace-relation-targets
trace-relation-details
5.6 Complete mathematical notation
math->tex
datum->tex
format-math-source
math->string
math-source?
math-source-text
math-source-spans
math-source-span?
math-source-span-start
math-source-span-end
math-source-span-path
math-source-span-role
5.7 Presentation policy and schedules
math-presentation
math-presentation?
classroom
present
choreograph
presentation-style?
presentation-style-anchor
presentation-style-history
presentation-style-start-group
presentation-style-new-parts
presentation-style-removed-parts
presentation-style-reflow
presentation-style-multiplication
presentation-style-pause-between-groups
presentation-style-duration
presentation-style-font-size
presentation-style-row-gap
presentation-style-max-visible-rows
presentation-plan?
presentation-plan-source
presentation-plan-style
presentation-plan-segments
presentation-plan-choreography
presentation-plan-allow-unverified?
plan-segment?
plan-segment-path
plan-segment-derivation
plan-segment-groups
plan-segment-context
plan-segment-verdict
plan-segment-shared?
presentation-phase?
presentation-phase-kind
presentation-phase-duration
presentation-phase-effect
presentation-phase-layout
presentation-phase-annotation
scheduled-phase?
scheduled-phase-segment
scheduled-phase-step
scheduled-phase-kind
scheduled-phase-start
scheduled-phase-duration
scheduled-phase-group
scheduled-phase-phase
math-checkpoint?
math-checkpoint-index
math-checkpoint-segment
math-checkpoint-step
math-checkpoint-time
math-checkpoint-state
math-checkpoint-case-path
plan-checkpoints
checkpoint-at
plan-schedule
plan-duration
plan-inspect
prepare-space
reveal-created
retire-cancelled
retire-removed
compact
hold
explain-math
transition
plan-with-choreography

5 Mathematical API🔗ℹ

 (require animate/math) package: animate

This module exports held model values, deterministic local checking, explicit rewrites, and presentation descriptions. It does not import rendering or external CAS-execution modules. All accessors and ordinary constructors here are pure when used with the default local prover. An explicitly installed custom prover must honor its documented callback contract.

5.1 Held states and occurrence identity🔗ℹ

procedure

(math datum [#:id id #:context ctx]) → math?

  datum : math-datum?
  id : symbol? = 'math
  ctx : math-context? = (math-context)
Constructs a held mathematical state with deterministic occurrence identities.

The expression remains held: term order, repeated occurrences, explicit units, zeroes, and unevaluated arithmetic are retained. The default namespace is 'math; supply different #:id values for independent roots. Occurrence paths exclude the operator and are zero-based. Initial domain requirements are retained in the context; a refuted definedness condition raises exn:fail:math?. No CAS or typesetter is loaded by this constructor.

procedure

(math? value) → boolean?

  value : any/c
Reports whether the value is a mathematical state.

procedure

(math-datum record) → math-datum?

  record : math?
Returns the exact held expression without normalizing it.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(math-id record) → symbol?

  record : math?
Returns the stable mathematical-state namespace.

Identity is deterministic and scoped to the mathematical root and derivation, not allocated by a process-global counter.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(math-context-of state) → math-context?

  state : math?
Returns the assumptions and retained domain of this state.

procedure

(math-occurrences record) → (and/c hash? immutable?)

  record : math?
Returns the operand-path map for this immutable state.

Keys are operand paths. Hash enumeration has no semantic order; use datum-paths or the ordered selector results when order matters.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(math-revision record) → any/c

  record : math?
Returns the deterministic derivation revision, not a process-global counter.

Identity is deterministic and scoped to the mathematical root and derivation, not allocated by a process-global counter.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(math-with-context state    
  requested-context    
  [#:scope scope]) → math?
  state : math?
  requested-context : math-context?
  scope : (or/c symbol? #f) = #f
Creates a scoped state while retaining the original domain restrictions.

Existing domain restrictions survive this update. An inconsistent context is rejected. Scope must be a symbol or false. A supplied scope changes the revision tag but does not silently allocate a new global identity namespace.

procedure

(math-occurrence-at state path) → occurrence?

  state : math?
  path : (listof exact-nonnegative-integer?)
Selects the occurrence at an exact zero-based operand path.

procedure

(math-inspect state path) → (and/c hash? immutable?)

  state : math?
  path : (listof exact-nonnegative-integer?)
Reports occurrence identity, held syntax, context, and revision.

procedure

(math-datum? x) → boolean?

  x : any/c
Recognizes supported scalar-expression data without evaluating it.

Recognizes finite real atoms, booleans, symbols, and proper symbol-headed application lists. The constructor additionally validates known operator arities. This predicate does not establish mathematical validity or real-valuedness.

procedure

(held-substitute x replacements) → math-datum?

  x : math-datum?
  replacements : (or/c hash? list?)
Performs simultaneous structural substitution and rejects traversal under binders.

Substitution is simultaneous: replacement results are not substituted again. It does not rebuild ancestors through simplifying CAS constructors. Traversal under binders is rejected rather than risking variable capture. The operation returns ordinary data and retains no replacement map.

procedure

(free-of? x target) → boolean?

  x : math-datum?
  target : math-datum?
Tests absence of a structurally equal complete subexpression.

Tests structural absence, not algebraic independence. Equivalent but differently written expressions are not treated as equal.

procedure

(datum-ref x p) → math-datum?

  x : math-datum?
  p : (listof exact-nonnegative-integer?)
Looks up a held subexpression by zero-based operand indices.

An empty path denotes the root. Each nonnegative index selects an operand, not a list element including the operator. Invalid paths raise a diagnostic.

procedure

(datum-paths x [p]) → (listof (listof exact-nonnegative-integer?))

  x : math-datum?
  p : (listof exact-nonnegative-integer?) = '()
Enumerates the root and descendants in preorder without sorting operands.

Returns the root first, followed by operands recursively in their stored order. The optional prefix is prepended to every returned path.

procedure

(occurrence? value) → boolean?

  value : any/c
Reports whether its argument is a occurrence value.

procedure

(occurrence-id record) → symbol?

  record : occurrence?
Returns the id field: stable occurrence identity, independent of rendered views.

Identity is deterministic and scoped to the mathematical root and derivation, not allocated by a process-global counter.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(occurrence-path record) → (listof exact-nonnegative-integer?)

  record : occurrence?
Returns the path field: zero-based path in this state only.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(occurrence-datum record) → math-datum?

  record : occurrence?
Returns the datum field: exact held subexpression.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(exn:fail:math? value) → boolean?

  value : any/c
Reports whether its argument is a exn:fail:math value.

procedure

(exn:fail:math-code record) → symbol?

  record : exn:fail:math?
Returns the code field: stable mathematical diagnostic category.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(exn:fail:math-details record) → list?

  record : exn:fail:math?
Returns the details field: ordered diagnostic context.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

parameter

(current-math-validation) → (or/c 'strict 'draft)

(current-math-validation mode) → void?
  mode : (or/c 'strict 'draft)
Defaults to 'strict. Strict construction rejects unresolved obligations; draft construction retains them. Both modes reject refuted operations. A draft presentation still requires an explicit visible-warning opt-in.

parameter

(current-math-prover) → procedure?

(current-math-prover prover) → void?
  prover : procedure?
Defaults to context-prove. The callback takes a mathematical context and a proposition and returns exactly one verification report for that same proposition. Mandatory keyword arguments and wrong arity are rejected when the parameter is set; malformed or unrelated evidence is rejected at application. The callback is used during construction and is not retained in a native scene.

5.2 Contexts and evidence🔗ℹ

procedure

(math-context [#:real real    
  #:assuming assumptions    
  #:definitions definitions]) → math-context?
  real : (listof symbol?) = '()
  assumptions : (listof math-datum?) = '()
  definitions : (or/c hash? list?) = '()
Validates real variables, ordered assumptions, and acyclic scoped definitions.

Only declared symbols are assumed real. Assumptions retain declaration order. Definitions may be a hash or a list of two-element name/expression lists; names must be symbols, duplicates in list input are rejected, and cycles are rejected. The stored definition hash is immutable. A definition is an abbreviation, not a new unconstrained variable.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(math-context? value) → boolean?

  value : any/c
Recognizes an immutable real-scalar context.

procedure

(math-context-real record) → (listof symbol?)

  record : math-context?
Returns real-variable declarations in declaration order.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(math-context-assumptions record) → (listof math-datum?)

  record : math-context?
Returns the ordered assumption propositions.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(math-context-definitions record) → (and/c hash? immutable?)

  record : math-context?
Returns the immutable map of scoped definitions.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(math-context-restrictions record) → (listof math-datum?)

  record : math-context?
Returns domain exclusions retained independently of current syntax.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(context-assume c guard) → math-context?

  c : math-context?
  guard : math-datum?
Adds a branch guard and the guard expression’s definedness conditions.

procedure

(context-add-restrictions c rs) → math-context?

  c : math-context?
  rs : (listof math-datum?)
Adds validated domain obligations without deleting existing exclusions.

procedure

(context-expand c x) → math-datum?

  c : math-context?
  x : math-datum?
Expands definitions and contextual equalities with a bounded substitution pass.

procedure

(context-prove c p) → verification?

  c : math-context?
  p : math-datum?
Checks definedness before reporting an established, refuted, or unknown proposition.

Returns established, refuted, or unknown evidence. Definedness is checked before algebraic identity reasoning, so simplifying a quotient cannot erase its excluded points. This is a bounded elementary checker, not a complete prover.

procedure

(context-signs c expr [fuel]) → (listof exact-integer?)

  c : math-context?
  expr : math-datum?
  fuel : exact-nonnegative-integer? = 24
Returns conservative possible signs; uncertainty is never treated as positivity.

The result is a conservative subset of '(-1 0 1). Its entries mean negative, zero, and positive. The default recursion budget is 24. Exhaustion returns uncertainty; it never silently assumes positivity.

procedure

(context-real? c x [fuel]) → boolean?

  c : math-context?
  x : math-datum?
  fuel : exact-nonnegative-integer? = 40
Conservatively establishes real-valuedness within a finite recursion budget.

The default recursion budget is 40. Failure to establish real-valuedness returns false, which does not prove non-real-valuedness.

procedure

(context-inconsistent? c) → boolean?

  c : math-context?
Reports an established inconsistency without guessing from unknown evidence.

procedure

(context-facts c) → (listof math-datum?)

  c : math-context?
Returns assumptions followed by retained domain restrictions.

procedure

(check-case-coverage c guards) → verification?

  c : math-context?
  guards : (listof math-datum?)
Checks exhaustiveness and disjointness over at most seven sign atoms.

Checks both exhaustiveness and pairwise disjointness using at most seven propositional sign atoms. Unsupported guards or a larger problem return unknown evidence. Branch declaration order is preserved separately by the derivation.

procedure

(verification? value) → boolean?

  value : any/c
Reports whether its argument is a verification value.

procedure

(verification-status record)

 → (or/c 'established 'refuted 'unknown)
  record : verification?
Returns the status field: three-valued decision.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(verification-method record) → symbol?

  record : verification?
Returns the method field: evidence source, not a formal-proof claim.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(verification-proposition record) → any/c

  record : verification?
Returns the proposition field: the exact proposition being checked.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(verification-obligations record) → list?

  record : verification?
Returns the obligations field: pending requirements in diagnostic order; empty after a decision.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(verification-message record) → (and/c string? immutable?)

  record : verification?
Returns the message field: copied diagnostic text.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(verification-details record) → any/c

  record : verification?
Returns the details field: snapshotted supporting metadata.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(established method proposition [details]) → verification?

  method : symbol?
  proposition : math-datum?
  details : any/c = '()
Creates immutable evidence for an established proposition.

This constructs evidence metadata; it does not itself prove the proposition. Custom provers and service adapters are trusted to supply truthful reports. Acyclic metadata containers, including strings, vectors, boxes, and hashes, are copied immutably; already validated verification records may be nested. Cyclic metadata, procedures, and opaque native resources are rejected. This prevents external result handles from changing previously recorded evidence.

procedure

(unknown method    
  proposition    
  [obligations    
  message    
  details]) → verification?
  method : symbol?
  proposition : math-datum?
  obligations : list? = (list proposition)
  message : string? = "Not established."
  details : any/c = '()
Creates pending evidence with explicit obligations and an immutable diagnostic.

Records explicit unresolved obligations. Unknown is never interpreted as true. Empty obligation lists still leave the report status unknown.

procedure

(refuted method proposition [message details]) → verification?

  method : symbol?
  proposition : math-datum?
  message : string? = "Refuted."
  details : any/c = '()
Creates immutable evidence for a refuted proposition.

Constructs a refutation report rather than throwing an exception. Application of a refuted rewrite is rejected even in draft mode.

procedure

(merge-verifications checks [proposition]) → verification?

  checks : (listof verification?)
  proposition : math-datum? = 'derivation
Combines ordered reports with refutation taking precedence over uncertainty.

Refutation takes precedence over unknown, and unknown takes precedence over established. Report order is retained in the combined details.

5.3 Selectors🔗ℹ

procedure

(whole) → selector?

Selects the complete root expression.

Selects the complete root. Selectors refer to the input snapshot of the operation, not a location remembered from a different revision.

procedure

(lhs [within]) → selector?

  within : selector? = (whole)
Selects the left operand of a relation within the containing selection.

The containing selection must resolve to a binary relation. It is not a text search for the material left of the first rendered equals sign.

procedure

(rhs [within]) → selector?

  within : selector? = (whole)
Selects the right operand of a relation within the containing selection.

The containing selection must resolve to a binary relation. The selector returns its second mathematical operand.

procedure

(numerator [within]) → selector?

  within : selector? = (whole)
Selects the numerator of an explicitly held quotient.

Requires a held quotient '(/ numerator denominator). It does not invent a quotient view of a product with a negative exponent.

procedure

(denominator [within]) → selector?

  within : selector? = (whole)
Selects the denominator of an explicitly held quotient.

Requires explicit quotient syntax. No implicit CAS normalization is used when resolving this selector.

procedure

(at-path p) → selector?

  p : (listof exact-nonnegative-integer?)
Selects an exact zero-based operand path and validates the path immediately.

Validates the path shape immediately. Range validation occurs against a specific held expression when the selector is resolved.

procedure

(matching datum    
  [#:occurrence ordinal    
  #:within within]) → selector?
  datum : math-datum?
  ordinal : (or/c exact-positive-integer? #f) = #f
  within : selector? = (whole)
Selects structural matches, optionally choosing a one-based occurrence ordinal.

Matches structural data within the selected subtree in preorder. #:occurrence is one-based. Without it, all matches are returned; an operation requiring one match diagnoses ambiguity instead of selecting the first.

procedure

(all-matching datum [#:within within]) → selector?

  datum : math-datum?
  within : selector? = (whole)
Selects every structural match in held preorder within the containing selection.

Returns all structural matches in preorder. Repeated equal values retain their distinct occurrence identities.

procedure

(operator-of [within]) → selector?

  within : selector? = (whole)
Selects the owning expression for inspection of an operator role.

Selects the owning mathematical expression. The visual adapter may then address its operator role; this selector does not create a separate AST operand.

procedure

(selector? value) → boolean?

  value : any/c
Reports whether its argument is a selector value.

procedure

(resolve-selector state s)

 → (listof (listof exact-nonnegative-integer?))
  state : (or/c math? math-datum?)
  s : selector?
Resolves an immutable selector to ordered operand paths in one snapshot.

procedure

(resolve-one state s) → (listof exact-nonnegative-integer?)

  state : (or/c math? math-datum?)
  s : selector?
Requires exactly one result and diagnoses missing or ambiguous selection.

procedure

(math-select state s) → (listof occurrence?)

  state : math?
  s : selector?
Returns selected mathematical occurrences, not anonymous rendered glyphs.

5.4 Operations and template rules🔗ℹ

procedure

(math-operation? value) → boolean?

  value : any/c
Reports whether its argument is a math-operation value.

procedure

(math-operation-name record) → symbol?

  record : math-operation?
Returns the name field: semantic operation name.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(math-operation-selector record) → selector?

  record : math-operation?
Returns the selector field: input focus resolved at application time.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(apply-math-operation state op [#:name name]) → rewrite-step?

  state : math?
  op : math-operation?
  name : symbol? = (math-operation-name op)
Applies and verifies one named operation before committing a new state.

The focus must resolve uniquely. The operation constructs a held edit, checks its obligations, retains the original domain restrictions, and commits a new immutable state. No animation or typesetting is performed.

procedure

(both-sides op    
  operand    
  [#:at focus    
  #:relationship relationship]) → math-operation?
  op : symbol?
  operand : math-datum?
  focus : selector? = (whole)
  relationship : symbol? = 'equivalence
Applies a held operation to both relation operands with explicit invertibility guards.

Accepts 'add, 'subtract, 'multiply, 'divide, or 'power. Equivalence is the default. Multiplication and division require the appropriate nonzero conditions. Multiplying an inequality by a known negative value reverses its direction; an undecided sign is not guessed. Squaring is available as an explicit 'implication, not as an automatic solution-preserving equivalence.

procedure

(cancel-addends [#:at focus #:pair pair]) → math-operation?

  focus : selector? = (whole)
  pair : (or/c list? #f) = #f
Cancels one specified or uniquely identified pair of additive inverses.

Cancels one additive-inverse pair in the selected sum. A supplied pair is a two-element list of zero-based signed-addend indices. With no pair, cancellation requires a unique match. More than one eligible pair is an ambiguity error.

procedure

(cancel-factor [#:at focus]    
  #:factor factor    
  [#:keep-one? keep-one?]) → math-operation?
  focus : selector? = (whole)
  factor : math-datum?
  keep-one? : boolean? = #f
Cancels a selected common factor only under an established nonzero condition.

Requires an explicitly held quotient and the specified common factor. The factor must be nonzero in the current context. Retained domain exclusions survive cancellation. With #:keep-one? #t, a visible unit is retained for a subsequent remove-unit step.

procedure

(remove-unit [#:at focus]) → math-operation?

  focus : selector? = (whole)
Removes an explicitly displayed unit factor as its own teaching step.

Removes an explicitly displayed multiplicative unit. This is separate from cancellation so its disappearance can receive its own animation phase.

procedure

(reduce-identities [#:at focus]) → math-operation?

  focus : selector? = (whole)
Reduces supported identities only inside the explicit focus.

Applies the implemented zero, unit, and sign identities within the selected focus. Unrelated portions of the held expression are not normalized.

procedure

(evaluate [#:at focus #:mode mode]) → math-operation?

  focus : selector? = (whole)
  mode : symbol? = 'all
Evaluates exact arithmetic at the selected focus, optionally one deepest layer.

The mode is 'all or 'deepest. Arithmetic is exact; non-perfect radicals and unsupported operations remain held. Equations remain visible equations instead of collapsing to booleans.

procedure

(rewrite-to target [#:at focus #:using rule]) → math-operation?

  target : math-datum?
  focus : selector? = (whole)
  rule : symbol? = 'rational-identity
Requests a checked focused target and records an honest coarse rewrite event.

The target is explicit held data. The implemented policy checks rational or polynomial identity and records a focused replacement. A rule name labels the step; it does not manufacture a fine-grained derivation that a CAS never supplied. Target equivalence does not authorize discarding domain restrictions.

procedure

(reorder-addends [#:at focus] #:order order) → math-operation?

  focus : selector? = (whole)
  order : (listof exact-nonnegative-integer?)
Permutes signed addends by explicit zero-based indices.

The order must be a permutation of all zero-based signed-addend indices. Signs travel with the terms. Missing, repeated, or out-of-range indices are rejected.

procedure

(zero-product [#:at focus]) → math-operation?

  focus : selector? = (whole)
Splits a real product equation into the direct zero-factor alternatives.

Requires a product equation equal to zero over real scalars. The result is an explicit disjunction of factor equations, retaining all alternatives.

procedure

(square-solutions [#:at focus]) → math-operation?

  focus : selector? = (whole)
Solves a real square equation using explicit positive, zero, or negative cases.

Requires a square equation. A positive right side produces positive- and negative-root alternatives; zero produces one alternative; a negative right side has no real solutions. An unknown sign is an unresolved obligation rather than an implicit choice of the positive branch.

procedure

(abbreviate name [#:at focus]) → math-operation?

  name : symbol?
  focus : selector? = (whole)
Replaces a selected expression by an equivalent scoped definition name.

The name must have a scoped definition, and the selected expression must match the defined value under the available checks. The definition remains in the context for subsequent reasoning and display.

procedure

(each-branch op) → math-operation?

  op : math-operation?
Applies one operation to each direct solution alternative in branch order.

Applies the supplied operation to each direct disjunction alternative. It does not recursively search arbitrary nested case trees.

procedure

(substitute replacements [#:at focus]) → math-operation?

  replacements : (or/c hash? list?)
  focus : selector? = (whole)
Snapshots a replacement map and constructs a held specialization operation.

Accepts a hash or an association list of replacement pairs. Captures an immutable copy of the caller’s replacement map when this operation is constructed. Subsequent caller mutation cannot change its result. The recorded relationship is specialization, not equation equivalence.

procedure

(conclude classification #:for variable) → math-operation?

  classification : symbol?
  variable : symbol?
Requests a checked classification as all real values or no real solutions.

Accepts 'all-real or 'no-solutions. These are checked classifications, not arbitrary labels. Original-domain restrictions prevent an incorrect claim that every real value is allowed.

procedure

(assert-step target    
  [#:at focus    
  #:reason reason]) → math-operation?
  target : math-datum?
  focus : selector? = (whole)
  reason : string? = "Author-supplied target."
Creates a deliberately unverified author target that strict mode cannot certify.

Creates an explicitly unverified author-supplied target. Strict mode rejects unresolved application. Draft presentation requires an explicit opt-in and displays an unverified warning.

syntax

(define-math-rule name
    #:metavariables (variable ...)
    #:from before-template
    #:to after-template)
Captures held templates without evaluating arithmetic. Optional clauses, in order, are #:in real-scalars, #:check polynomial-identity, #:requires (condition ...), #:merge merge-expression, and #:version version-expression. The alternative check is author-assertion; the domain is currently only real-scalars. Requires clauses are captured templates. Merge and version expressions are ordinary evaluated configuration values.
(define-math-rule distribute-left
  #:metavariables (u v w)
  #:from (* u (+ v w))
  #:to (+ (* u v) (* u w))
  #:check polynomial-identity)
Repeated target occurrences of one source metavariable create explicit copies. Several source occurrences contributing to a target require #:merge 'merge.

procedure

(make-math-rule name    
  variables    
  before    
  after    
  [#:requires requires    
  #:merge merge    
  #:version version    
  #:check check]) → math-rule?
  name : symbol?
  variables : (listof symbol?)
  before : math-datum?
  after : math-datum?
  requires : (listof math-datum?) = '()
  merge : (or/c symbol? #f) = #f
  version : exact-positive-integer? = 1
  check : symbol? = 'polynomial-identity
Validates held templates, metavariables, merge policy, and rule version.

Metavariables are unique symbols in declaration order. Templates stay held. Checks are 'polynomial-identity or 'author-assertion. A repeated source metavariable requires an explicit #:merge 'merge policy before several source occurrences can contribute to a destination. Rule versions are positive exact integers.

procedure

(math-rule? value) → boolean?

  value : any/c
Reports whether its argument is a math-rule value.

procedure

(math-rule-name record) → symbol?

  record : math-rule?
Returns the name field: rule identity.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(use-rule rule [#:at focus]) → math-operation?

  rule : math-rule?
  focus : selector? = (whole)
Creates an operation from a trace-aware held rule template.

Creates an operation descriptor. The selector is resolved and the rule is checked only when the operation is applied to a mathematical state.

procedure

(apply-rule rule [#:at focus]) → math-operation?

  rule : math-rule?
  focus : selector? = (whole)
Creates an operation from a trace-aware held rule template.

An alias of use-rule. It creates an operation, not an applied rewrite step. Use apply-rewrite for immediate application.

procedure

(apply-rewrite rule    
  state    
  [#:name name    
  #:at focus]) → rewrite-step?
  rule : math-rule?
  state : math?
  name : symbol? = (math-rule-name rule)
  focus : selector? = (whole)
Applies a traceable template rule directly to a mathematical state.

Combines use-rule with apply-math-operation. The requested step name is independent of the reusable rule name.

procedure

(template-bindings template value variables)

 → 
(and/c hash? immutable?)
(and/c hash? immutable?)
  template : math-datum?
  value : math-datum?
  variables : (listof symbol?)
Returns structural bindings and all source occurrence witnesses.

Returns two values: an immutable binding hash and an immutable hash of ordered source witness paths. Matching is structural; it does not silently commute or reassociate terms. Conflicting repeated metavariables raise an error.

5.5 Derivations and branches🔗ℹ

syntax

(steps [name operation] ...)

Constructs a nonempty reusable mathematical recipe. Each name is a literal identifier; each operation is a math-operation? or nested step-sequence?. Sibling names are unique. No mathematical state is advanced until the recipe is used in a named derive slot. Recipes carry no presentation timing or native resources.
(define (subtract-and-cancel amount)
  (steps [subtract (both-sides 'subtract amount)]
         [cancel (cancel-addends #:at (lhs))]))
(derive problem [isolate-term (subtract-and-cancel 5)])
A recipe is not an elementary operation: use it in derive, not as an argument to apply-math-operation or each-branch. For branchwise recipes, wrap their elementary operations in each-branch explicitly.

procedure

(steps/proc entries) → step-sequence?

  entries : list?
Constructs a recipe from a nonempty ordered list of pairs (cons name operation). The cdr is an elementary operation or another recipe. Copies and validates the sibling list; duplicate symbols and invalid operations are rejected before any operation is applied.

procedure

(step-sequence? value) → boolean?

  value : any/c
Recognizes an immutable unapplied recipe created by steps or steps/proc. The raw constructor is private.

procedure

(derivation-tree record) → (listof derivation-node?)

  record : derivation?
Returns ordered applied root nodes. Their elementary leaves are exactly derivation-steps, in order. Composite nodes do not create extra checkpoints.

procedure

(derivation-node? value) → boolean?

  value : any/c
Recognizes one applied elementary leaf or composite move. Its raw constructor is private.

procedure

(derivation-node-path record) → (listof symbol?)

  record : derivation-node?
Returns its nonempty derivation-relative hierarchical address. Case paths are separate. This is an authoring address, not a mathematical occurrence ID or a rendered view ID.

procedure

(derivation-node-before record) → math?

  record : derivation-node?
Returns the exact input state of the first elementary descendant.

procedure

(derivation-node-after record) → math?

  record : derivation-node?
Returns the exact output state of the last elementary descendant.

procedure

(derivation-node-children record) → (listof derivation-node?)

  record : derivation-node?
Returns ordered children for a composite and an empty list for an elementary leaf.

procedure

(derivation-node-step record) → (or/c rewrite-step? #f)

  record : derivation-node?
Returns the original primitive rewrite for a leaf, or #f for a composite. No opaque replacement rewrite is fabricated for a composite.

procedure

(derivation-node-at source address) → derivation-node?

  source : (or/c derivation? case-derivation? solution-check?)
  address : (or/c symbol? (listof symbol?))
Looks up an exact nonempty hierarchical path, or an unambiguous local symbol. Repeated child names in different moves require full paths. A symbol is not allowed to guess a case branch. A case-qualified path prepends branch names to the move path. Unknown or ambiguous addresses raise a mathematical diagnostic.
(derivation-node-at solution '(isolate-term cancel-five))
(derivation-node-at general-solution '(ordinary isolate-x))

procedure

(derivation-node-relation record) → symbol?

  record : derivation-node?
Conservatively summarizes leaf relationships. Identical kinds are retained; expression/equation equivalences together give 'equivalence; equivalences plus implications give 'implication; equivalences plus specializations give 'specialization. Other mixtures, including implication plus specialization, are 'mixed. This does not strengthen any child into equivalence.

procedure

(derivation-node-verification record) → verification?

  record : derivation-node?
Combines ordered primitive evidence without adding endpoint checks or external CAS calls. Established child checks do not imply that the move preserves all solutions; inspect derivation-node-relation separately.

procedure

(derivation-step-paths record) → (listof (listof symbol?))

  record : derivation?
Returns full nonempty leaf paths in chronological order. Even a flat leaf has a one-element path here. Schedule accessors retain a symbol for a flat root leaf and return a full symbol list for a nested leaf.

syntax

(derive initial [name operation] ...)

Evaluates each operation expression and applies it in declaration order. Names are captured as symbols. The input is a held state or an existing linear derivation. Entries accept elementary operations or recipes. Names must be unique among siblings; child names may repeat in different moves. An empty derivation is allowed. Every elementary checkpoint and occurrence trace is retained unchanged.
(derive (math '(= (+ (* 3 x) 5) 17)
              #:context (math-context #:real '(x)))
  [subtract-five (both-sides 'subtract 5)]
  [cancel-five (cancel-addends #:at (lhs))]
  [compute-right (evaluate #:at (rhs))])

procedure

(derive/proc initial named-operations) → derivation?

  initial : (or/c math? derivation?)
  named-operations : list?
Appends named operations in order while rejecting duplicate step names.

The second argument is an ordered list of pairs whose car is a symbol step name and whose cdr is an elementary operation or recipe. Top-level names must be unique in the extended derivation; child names are sibling-local. No partial derivation is returned on failure, and an existing derivation is never mutated.

syntax

(derive-cases initial [name guard [step operation] ...] ...)

Builds named parameter cases, checks guard coverage, and adds the guard to each branch’s immutable context. A branch can instead have the form [name guard #:then factory], where the factory consumes the scoped state and returns a derivation or a nested case tree. Ordinary step names are local to a branch. Branch entries can contain recipes. Top-level names must remain unique along a complete path including the prefix; nested names are resolved by full paths.

procedure

(make-case-derivation initial branch-specs) → case-derivation?

  initial : (or/c math? derivation?)
  branch-specs : list?
Builds scoped branches only after checking case coverage.

Requires a nonempty list of three-element branch specifications, (list name guard factory). Names are symbols and guards are validated mathematical data. The factory accepts the scoped input state, requires no keyword arguments, and returns a derivation or case tree. Factories run during construction, must honor the held-state contract, and are not retained in scenes. Duplicate sibling names and unsupported strict-mode coverage are rejected.

procedure

(derivation? value) → boolean?

  value : any/c
Reports whether its argument is a derivation value.

procedure

(derivation-initial record) → math?

  record : derivation?
Returns the initial field: initial checkpoint.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(derivation-steps record) → (listof rewrite-step?)

  record : derivation?
Returns the chronological elementary rewrite list, not the move tree. Nested recipes are flattened here without dropping states or replacing their original witnesses.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(derivation-final record) → math?

  record : derivation?
Returns the final field: last checkpoint, or initial state for an empty derivation.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(case-branch? value) → boolean?

  value : any/c
Reports whether its argument is a case-branch value.

procedure

(case-branch-name record) → symbol?

  record : case-branch?
Returns the name field: unique sibling branch name.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(case-branch-guard record) → math-datum?

  record : case-branch?
Returns the guard field: scoped parameter condition.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(case-branch-derivation record) → any/c

  record : case-branch?
Returns the derivation field: nested derivation or case tree.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(case-derivation? value) → boolean?

  value : any/c
Reports whether its argument is a case-derivation value.

procedure

(case-derivation-prefix record) → derivation?

  record : case-derivation?
Returns the prefix field: shared mathematical prefix.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(case-derivation-branches record) → (listof case-branch?)

  record : case-derivation?
Returns the branches field: declared branch presentation order.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(case-derivation-coverage record) → verification?

  record : case-derivation?
Returns the coverage field: exhaustiveness and disjointness evidence.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(solution-check? value) → boolean?

  value : any/c
Reports whether its argument is a solution-check value.

procedure

(solution-check-problem record) → math?

  record : solution-check?
Returns the problem field: original problem and domain.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(solution-check-variable record) → symbol?

  record : solution-check?
Returns the variable field: variable being specialized.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(solution-check-value record) → math-datum?

  record : solution-check?
Returns the value field: candidate value.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(solution-check-derivation record) → (or/c derivation? #f)

  record : solution-check?
Returns the derivation field: visible substitution steps, absent for an undefined candidate.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(solution-check-verification record) → verification?

  record : solution-check?
Returns the verification field: candidate membership report, not solution-set completeness.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(after d [label]) → math?

  d : (or/c math? derivation? case-derivation? solution-check?)
  label : (or/c symbol? (listof symbol?) #f) = #f
Returns a unique endpoint or named checkpoint, requiring an explicit branch for case trees.

Without a label, a linear derivation returns its final state. A case tree has no unique final state: select a branch path or inspect its branches explicitly. A named path uses any required branch symbols followed by a move/leaf path. Both composite and elementary addresses are accepted; a composite returns its final child’s state. Unqualified symbols must be unambiguous in the requested scope.

procedure

(derivation-step d label) → rewrite-step?

  d : (or/c derivation? case-derivation?)
  label : (or/c symbol? (listof symbol?))
Looks up an elementary leaf by hierarchical path or unambiguous symbol. A composite address raises an error: use derivation-node-at for inspection or after for its endpoint. Case paths precede derivation-relative move/leaf paths.

procedure

(derivation-states d) → (listof math?)

  d : (or/c derivation? case-derivation?)
Returns checkpoint states in significant derivation and branch order.

Combines rewrite evidence and parameter-case coverage without external CAS calls.

procedure

(check-solution problem    
  #:for variable    
  #:value value) → solution-check?
  problem : math?
  variable : symbol?
  value : math-datum?
Checks a candidate in the original domain before constructing visible substitution steps.

Checks the candidate against the original problem and its original context. A successful substitution check establishes membership, not completeness of the solution set. An undefined or unestablished-domain candidate has no visible checking derivation.

procedure

(rewrite-step? value) → boolean?

  value : any/c
Reports whether its argument is a rewrite-step value.

procedure

(rewrite-step-name record) → symbol?

  record : rewrite-step?
Returns the name field: unique step name within its derivation path.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(rewrite-step-before record) → math?

  record : rewrite-step?
Returns the before field: exact input checkpoint.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(rewrite-step-after record) → math?

  record : rewrite-step?
Returns the after field: exact output checkpoint.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(rewrite-step-rule record) → symbol?

  record : rewrite-step?
Returns the rule field: applied mathematical operation.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(rewrite-step-focus record)

 → (listof exact-nonnegative-integer?)
  record : rewrite-step?
Returns the focus field: selected input location.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(rewrite-step-bindings record) → (and/c hash? immutable?)

  record : rewrite-step?
Returns the bindings field: held metavariable bindings.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(rewrite-step-links record) → (listof path-link?)

  record : rewrite-step?
Returns the links field: ordered structural provenance.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(rewrite-step-trace record) → (listof trace-relation?)

  record : rewrite-step?
Returns the trace field: typed occurrence relationships in deterministic order.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(rewrite-step-relation record) → symbol?

  record : rewrite-step?
Returns the relation field: equivalence, implication, or specialization classification.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(rewrite-step-verification record) → verification?

  record : rewrite-step?
Returns the verification field: evidence and outstanding conditions.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(rewrite-step-details record) → any/c

  record : rewrite-step?
Returns the details field: snapshotted rule-specific metadata.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(rewrite-step-version record) → exact-positive-integer?

  record : rewrite-step?
Returns the version field: rule-version identity for reproducibility.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(trace-descendants step item) → (listof occurrence?)

  step : rewrite-step?
  item : (or/c occurrence? symbol?)
Returns traced descendants in numerical operand traversal order.

procedure

(path-link? value) → boolean?

  value : any/c
Reports whether its argument is a path-link value.

procedure

(path-link-source record) → (listof exact-nonnegative-integer?)

  record : path-link?
Returns the source field: source location in the input snapshot.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(path-link-target record) → (listof exact-nonnegative-integer?)

  record : path-link?
Returns the target field: destination location in the output snapshot.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(path-link-kind record) → symbol?

  record : path-link?
Returns the kind field: preserve, container, reorder, or copy relationship.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(path-link-subtree? record) → boolean?

  record : path-link?
Returns the subtree? field: whether an exact equal subtree is witnessed.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(trace-relation? value) → boolean?

  value : any/c
Reports whether its argument is a trace-relation value.

procedure

(trace-relation-kind record) → symbol?

  record : trace-relation?
Returns the kind field: preserve, copy, merge, cancel, evaluate, or related event.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(trace-relation-sources record) → (listof symbol?)

  record : trace-relation?
Returns the sources field: source occurrence identities in witness order.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(trace-relation-targets record) → (listof symbol?)

  record : trace-relation?
Returns the targets field: target occurrence identities in witness order.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(trace-relation-details record) → any/c

  record : trace-relation?
Returns the details field: semantic explanation, not animation timing.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

5.6 Complete mathematical notation🔗ℹ

procedure

(math->tex d [#:multiplication m]) → string?

  d : (or/c math? math-datum?)
  m : symbol? = 'school
Returns complete TeX source without evaluating or normalizing the expression.

An alias of datum->tex. Both held data and mathematical states are accepted, and neither is normalized for display.

procedure

(datum->tex d [#:multiplication m]) → string?

  d : (or/c math? math-datum?)
  m : symbol? = 'school
Returns complete TeX source without evaluating or normalizing the expression.

procedure

(format-math-source datum 
  [#:multiplication multiplication]) 
 → math-source?
  datum : (or/c math? math-datum?)
  multiplication : symbol? = 'school
Formats one complete formula and retains half-open source spans for its occurrences.

Returns a complete TeX source string plus semantic half-open source ranges, measured in Racket string character indices, not UTF-8 bytes. Expression ranges may contain subordinate leaf or operator ranges. No TeX process is run.

procedure

(math->string x) → string?

  x : (or/c math? math-datum?)
Prints the held S-expression for inspection.

Produces the readable diagnostic notation used by –steps and context captions. It is not a parser round-trip format.

procedure

(math-source? value) → boolean?

  value : any/c
Reports whether its argument is a math-source value.

procedure

(math-source-text record) → (and/c string? immutable?)

  record : math-source?
Returns the text field: one complete TeX formula.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(math-source-spans record) → (listof math-source-span?)

  record : math-source?
Returns the spans field: start-ordered possibly nested semantic ranges.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(math-source-span? value) → boolean?

  value : any/c
Reports whether its argument is a math-source-span value.

Returns the start field: inclusive character offset.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(math-source-span-end record) → exact-positive-integer?

  record : math-source-span?
Returns the end field: exclusive character offset.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

Returns the path field: mathematical owner location.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(math-source-span-role record) → symbol?

  record : math-source-span?
Returns the role field: expression, atom, relation, or operator role.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

5.7 Presentation policy and schedules🔗ℹ

procedure

(math-presentation [#:anchor anchor 
  #:history history 
  #:start-group start-group 
  #:new-parts new-parts 
  #:removed-parts removed-parts 
  #:reflow reflow 
  #:multiplication multiplication 
  #:pause-between-groups pause 
  #:duration step-duration 
  #:font-size font-size 
  #:row-gap row-gap 
  #:max-visible-rows max-rows]) 
 → math-presentation?
  anchor : symbol? = 'relation
  history : symbol? = 'keep-completed-groups
  start-group : symbol? = 'copy
  new-parts : symbol? = 'fade
  removed-parts : symbol? = 'fade
  reflow : symbol? = 'staged
  multiplication : symbol? = 'school
  pause : (and/c real? (>=/c 0)) = 3/5
  step-duration : (and/c real? positive?) = 4/5
  font-size : (and/c real? positive?) = 11/20
  row-gap : (and/c real? positive?) = 21/20
  max-rows : (and/c exact-integer? (>=/c 2)) = 5
Constructs validated layout and timing policy with exact rational defaults.

The anchor is 'relation or 'center. History is 'keep-completed-groups, 'keep-all-checkpoints, or 'replace. Start-group is 'copy or 'replace. The supported appearance effect is 'fade; unsupported effects are rejected. Reflow is 'staged or 'simultaneous, and multiplication is 'school or 'explicit. Durations and pauses are seconds; font size and row gap are world units. Values must be finite. Pauses may be zero, other sizes and durations are positive, and at least two visible rows are required. Defaults use exact rational numbers.

procedure

(math-presentation? value) → boolean?

  value : any/c
Recognizes a validated presentation style.

Provides the exact-time, staged, retained-history classroom style.

procedure

(present source    
  [#:style style    
  #:groups groups    
  #:case case-path    
  #:case-layout case-layout    
  #:allow-unverified? allow?]) → presentation-plan?
  source : (or/c derivation? case-derivation? solution-check?)
  style : math-presentation? = classroom
  groups : (or/c 'top-level 'steps list? hash? #f) = #f
  case-path : (or/c symbol? (listof symbol?) #f) = #f
  case-layout : (or/c 'complete-paths 'shared-prefix)
   = 'complete-paths
  allow? : boolean? = #f
Builds an explicit presentation while retaining verification status and case context.

Groups partition elementary steps exactly once in order. 'top-level (and the default #f) uses one group per top-level move or elementary root; 'steps uses one per elementary rewrite. Explicit groups may name moves or leaves; move references expand before partition validation. For several cases, either symbolic mode applies to every case, or a hash maps case paths to modes or group lists. Missing hash entries use the top-level default. The case selector is a symbol or a list of branch symbols. Strict presentation rejects unverified derivations unless #:allow-unverified? #t is supplied; that flag must be a boolean and causes a visible warning.

The default 'complete-paths plays a complete derivation for every leaf. With 'shared-prefix, each nonempty common mathematical prefix is played once before its descendant branch suffixes. Group declarations still describe complete leaf paths; they are validated first, then projected onto the emitted segments. Incompatible partitions of a shared prefix are rejected. Selecting a single #:case always restores its full prefix, irrespective of layout.

syntax

(choreograph plan [step-key phase ...] ...)

Adds explicit phase sequences to a presentation without changing its mathematical derivation. Keys are captured as symbols or nonempty lists. Complete case-plus-step paths take precedence over derivation-relative paths, then local-name shorthand, then defaults. Shorthand matching different relative leaf paths is rejected. Composite moves are not elementary phase targets. Duplicate keys in one call are rejected. Use a precise address to replace an existing precise override.
(choreograph plan
  [cancel-five (retire-cancelled #:duration 2/5)
               (hold 1/2)
               (compact #:duration 2/5)])

procedure

(presentation-style? value) → boolean?

  value : any/c
Reports whether its argument is a presentation-style value.

procedure

(presentation-style-anchor record) → symbol?

  record : presentation-style?
Returns the anchor field: relation or center alignment.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(presentation-style-history record) → symbol?

  record : presentation-style?
Returns the history field: retained checkpoint policy.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(presentation-style-start-group record) → symbol?

  record : presentation-style?
Returns the start-group field: copy or replacement policy.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(presentation-style-new-parts record) → symbol?

  record : presentation-style?
Returns the new-parts field: validated appearance effect.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(presentation-style-removed-parts record) → symbol?

  record : presentation-style?
Returns the removed-parts field: validated disappearance effect.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(presentation-style-reflow record) → symbol?

  record : presentation-style?
Returns the reflow field: staged or simultaneous layout changes.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(presentation-style-multiplication record) → symbol?

  record : presentation-style?
Returns the multiplication field: school or explicit notation.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(presentation-style-pause-between-groups record)

 → (and/c real? (>=/c 0))
  record : presentation-style?
Returns the pause-between-groups field: seconds of reading time after each group.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(presentation-style-duration record) → (and/c real? positive?)

  record : presentation-style?
Returns the duration field: default step duration in seconds.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(presentation-style-font-size record) → (and/c real? positive?)

  record : presentation-style?
Returns the font-size field: formula size in local world units.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(presentation-style-row-gap record) → (and/c real? positive?)

  record : presentation-style?
Returns the row-gap field: requested row separation in world units.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

Returns the max-visible-rows field: at least two visible rows.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(presentation-plan? value) → boolean?

  value : any/c
Reports whether its argument is a presentation-plan value.

procedure

(presentation-plan-source record) → any/c

  record : presentation-plan?
Returns the source field: original derivation, cases, or candidate check.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(presentation-plan-style record) → math-presentation?

  record : presentation-plan?
Returns the style field: validated immutable presentation policy.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(presentation-plan-segments record) → (listof plan-segment?)

  record : presentation-plan?
Returns the segments field: chronological branch presentations.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(presentation-plan-choreography record)

 → (and/c hash? immutable?)
  record : presentation-plan?
Returns the choreography field: step or case-step keys to ordered phase lists.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(presentation-plan-allow-unverified? record) → boolean?

  record : presentation-plan?
Returns the allow-unverified? field: whether a visible draft warning is required.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(plan-segment? value) → boolean?

  value : any/c
Reports whether its argument is a plan-segment value.

procedure

(plan-segment-path record) → (listof symbol?)

  record : plan-segment?
Returns the path field: case path in declared branch order.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(plan-segment-derivation record) → derivation?

  record : plan-segment?
Returns this segment’s mathematical steps. A shared segment contains just its common prefix; a branch suffix starts at the corresponding prefix endpoint. Under 'complete-paths, the segment contains the entire selected leaf.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(plan-segment-groups record) → list?

  record : plan-segment?
Returns the normalized ordered partition of elementary keys. A flat root leaf uses a symbol; a nested leaf uses its complete derivation-relative symbol path.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(plan-segment-context record) → math-context?

  record : plan-segment?
Returns the context field: context displayed with this segment.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(plan-segment-verdict record) → (or/c verification? #f)

  record : plan-segment?
Returns the verdict field: optional candidate-check report.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(plan-segment-shared? record) → boolean?

  record : plan-segment?
Reports whether this segment presents a common mathematical prefix rather than one terminal case. A true result does not itself assert a completed solution.

procedure

(presentation-phase? value) → boolean?

  value : any/c
Reports whether its argument is a presentation-phase value.

procedure

(presentation-phase-kind record) → symbol?

  record : presentation-phase?
Returns the kind field: phase behavior.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(presentation-phase-duration record) → (and/c real? (>=/c 0))

  record : presentation-phase?
Returns the duration field: seconds; zero allowed only for an explicit hold.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(presentation-phase-effect record) → symbol?

  record : presentation-phase?
Returns the effect field: fade, move, or none.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(presentation-phase-layout record) → symbol?

  record : presentation-phase?
Returns the layout field: held or destination layout.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(presentation-phase-annotation record)

 → (or/c #f (list/c math? string?))
  record : presentation-phase?
Returns the held state and immutable single-line caption for an explanatory inset, or #f for an ordinary phase. Inspection performs no typesetting.

procedure

(scheduled-phase? value) → boolean?

  value : any/c
Reports whether its argument is a scheduled-phase value.

Returns the segment field: zero-based segment index.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(scheduled-phase-step record)

 → (or/c symbol? (listof symbol?) #f)
  record : scheduled-phase?
Returns the canonical derivation-relative leaf key: a symbol for a flat root leaf, a full symbol list for a nested leaf, or #f for group/segment phases.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(scheduled-phase-kind record) → symbol?

  record : scheduled-phase?
Returns the kind field: scheduled phase category.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(scheduled-phase-start record) → (and/c real? (>=/c 0))

  record : scheduled-phase?
Returns the start field: absolute start time in seconds.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(scheduled-phase-duration record) → (and/c real? (>=/c 0))

  record : scheduled-phase?
Returns the duration field: phase duration in seconds.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(scheduled-phase-group record) → exact-integer?

  record : scheduled-phase?
Returns the group field: group index; minus one before the first group.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(scheduled-phase-phase record) → (or/c presentation-phase? #f)

  record : scheduled-phase?
Returns the phase field: explicit effect description when applicable.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(math-checkpoint? value) → boolean?

  value : any/c
Reports whether its argument is a math-checkpoint value.

Returns the index field: stable chronological checkpoint index.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

Returns the segment field: owning segment index.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(math-checkpoint-step record)

 → (or/c symbol? (listof symbol?) #f)
  record : math-checkpoint?
Returns the canonical committed leaf key (symbol or full relative symbol path), or #f for the initial state.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(math-checkpoint-time record) → (and/c real? (>=/c 0))

  record : math-checkpoint?
Returns the time field: absolute commit time in seconds.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(math-checkpoint-state record) → math?

  record : math-checkpoint?
Returns the state field: committed mathematical state.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(math-checkpoint-case-path record) → (listof symbol?)

  record : math-checkpoint?
Returns the case-path field: owning case path.

This accessor is pure. It does not copy, reorder, render, or mutate the record.

procedure

(plan-checkpoints plan) → immutable-vector?

  plan : presentation-plan?
Assigns deterministic checkpoint indices in chronological plan order.

procedure

(checkpoint-at plan time) → math-checkpoint?

  plan : presentation-plan?
  time : (and/c real? (>=/c 0))
Returns the latest committed mathematical checkpoint at the requested time.

Returns the latest mathematical checkpoint at or before the requested time. Animation interiors do not invent partial mathematical assertions.

procedure

(plan-schedule plan) → (listof scheduled-phase?)

  plan : presentation-plan?
Computes an ordered exact-time phase schedule without creating native scenes.

Entries are in chronological order, with zero-duration mathematical checkpoint records included. These data describe presentation; they are not a second frame-sampling engine. Native compilation uses ordinary animate scenes.

procedure

(plan-duration plan) → (and/c real? (>=/c 0))

  plan : presentation-plan?
Sums the phase durations in seconds; exact inputs retain exactness.

procedure

(plan-inspect plan t) → scheduled-phase?

  plan : presentation-plan?
  t : (and/c real? (>=/c 0))
Selects a half-open phase interval, with the final endpoint handled explicitly.

Time lies in the closed interval from zero to plan-duration. Active phase intervals are half-open. The total endpoint returns the final phase.

procedure

(prepare-space [#:duration d]) → presentation-phase?

  d : (and/c real? positive?) = 1/2
Moves preserved material to reserve space before revealing new parts.

Moves surviving parts to prepared positions before new material appears. The duration is measured in seconds and must be positive and finite.

procedure

(reveal-created [#:effect effect    
  #:duration d]) → presentation-phase?
  effect : symbol? = 'fade
  d : (and/c real? positive?) = 2/5
Fades in newly introduced material after space has been prepared.

Fades newly created material in while the established layout is held. Only 'fade is supported in this release.

procedure

(retire-cancelled [#:effect effect    
  #:layout layout    
  #:duration d]) → presentation-phase?
  effect : symbol? = 'fade
  layout : symbol? = 'hold
  d : (and/c real? positive?) = 2/5
Fades cancelled material while holding the surrounding layout fixed.

Fades cancelled material out without moving surviving parts. Only 'fade and 'hold layout are supported. Follow with a hold and compact to separate cancellation from closing the resulting gap.

procedure

(retire-removed [#:effect effect    
  #:layout layout    
  #:duration d]) → presentation-phase?
  effect : symbol? = 'fade
  layout : symbol? = 'hold
  d : (and/c real? positive?) = 2/5
Fades removed material while holding the surrounding layout fixed.

Uses the same held-layout retirement mechanism as cancellation but names a general removal event. It does not implicitly compact the expression.

procedure

(compact [#:duration d]) → presentation-phase?

  d : (and/c real? positive?) = 2/5
Closes reserved gaps by moving survivors to their prepared positions.

Moves surviving parts to their complete destination layout after retirement. The duration is positive and finite seconds. Reordered signed terms move in rigid units along two separated native-motion legs. Cancellation that creates a unit coefficient introduces that coefficient only after compaction; an explicit reveal-created phase can separate those actions further.

procedure

(hold d) → presentation-phase?

  d : (and/c real? (>=/c 0))
Retains the current presentation state for a nonnegative duration.

The duration may be zero. A hold adds no mathematical checkpoint or scene-state mutation.

procedure

(explain-math state    
  [#:caption caption    
  #:duration duration]) → presentation-phase?
  state : (or/c math? math-datum?)
  caption : string? = ""
  duration : (and/c real? positive?) = 2
Introduces a held mathematical inset without changing the working derivation. The caption must be a single line. Native preparation typesets the complete inset with the lesson and reserves a lower display band. The inset fades in for one fifth of its duration, holds for three fifths, then fades out for one fifth. It advances presentation time but does not add or advance a mathematical checkpoint. The author supplies the explanatory content; this is not a new proof rule or an implicit CAS calculation.
(choreograph plan
  [add-nine
    (explain-math '(= (expt (/ 6 2) 2) 9)
                  #:caption "Half the coefficient of x, then square it")
    (prepare-space)
    (reveal-created)])

procedure

(transition [#:duration d]) → presentation-phase?

  d : (and/c real? positive?) = 4/5
Performs a semantic replacement without displaying a hybrid expression. The outgoing mathematical unit fades out during the first 9/20 of the duration, survivors move during 1/10, and the incoming unit fades in during the final 9/20. The new unit is invisible until all outgoing ink has disappeared. This visibility barrier also applies under simultaneous reflow. Unaffected expressions keep their provenance and are not glyph-matched by shape.

procedure

(plan-with-choreography plan overrides) → presentation-plan?

  plan : presentation-plan?
  overrides : list?
Validates named phase overrides and returns a new immutable plan.

Overrides are an ordered list of (cons step-key phases). A key is a step name or a list of branch symbols followed by the step name. Each phase list is nonempty. Unknown keys, duplicate keys within one call, and invalid phase values are rejected. A case-specific override takes precedence over an unqualified step-name override.