neco-expr
neco-expr stores exact values in expression graphs and resolves them, per consumer, into certified floating-point values. A resolved result carries a finite f64, a dyadic enclosure at the requested precision, and an exact absolute error bound. The descent to floating point happens only at that final step, and every intermediate value stays exact.
Usage
This example stores the exact value one as an atom and resolves it at 20 bits of absolute precision:
use ;
use Monomial;
let mut graph = new;
let expression = graph
.push
.expect;
let mut atoms = new;
let atom_value = Monomial;
atoms
.insert
.expect;
let consumer = new;
let mut requirements = new;
requirements
.insert
.expect;
let mut assignments = new;
assignments
.insert
.expect;
let = new
.resolve_all
.expect;
let certified = resolved
.get
.expect
.as_ref
.expect;
assert_eq!;
Expressions and exact values
ExactValue has three ordered layers:
Monomial: a normalized monomialFormSum: a normalized formal sumAlgebraic: a real algebraic number identified by a minimal polynomial and root index
The graph is built from two types:
ExprGraph: an insertion-ordered arenaExprNode: atoms, negation, arithmetic operations, and reduced rational powers
Operation nodes may reference only previously inserted nodes, so every graph is acyclic.
For example, the golden ratio is built from a square-root atom and exact constants. The addition produces a layer-2 formal sum. Resolution returns an enclosure within the requested width and a finite floating-point value selected from it:
phi = (1 + 5^(1/2)) / 2
The operation and input layers determine the result layer:
| Operation | Inputs | Result |
|---|---|---|
| Negation | Any layer | Input layer |
| Addition, subtraction | Layers 1 and 2 | FormSum |
| Addition, subtraction | Includes layer 3 | Algebraic |
| Multiplication, division | Two Monomial values |
Monomial |
| Multiplication, division | Up to layer 2 | FormSum |
| Multiplication, division | Includes layer 3 | Algebraic |
| Integer power | Any layer | Input layer |
| Proper rational power | Monomial |
Monomial |
| Proper rational power | FormSum |
Algebraic |
| Proper rational power | Algebraic |
Algebraic |
Declarations and resolution
Resolution takes four independent inputs:
ExprGraph: expression nodesAtomStore: atom IDs and exact valuesPrecisionRequirements: consumer IDs and absolute precisionAssignments: consumer IDs and expression IDs
Resolution is a single call:
Resolver::resolve_all: resolves every consumer in ID order
The call returns three values:
EvaluationCache: exact values or evaluation failures for reached expression IDsIsolationCache: algebraic isolating intervals reusable for the same expression ID and precisionResolvedValues: aCertifiedF64or resolution failure for every requested consumer
Unknown expression or atom IDs are not stored in the evaluation cache; they become resolution failures of the requesting consumer. When one consumer fails, its failure is stored in the result map and resolution continues with the remaining consumers. The outer result reports failure only when a cache or the result map itself cannot be stored.
Certified floating-point values
CertifiedF64 contains three values:
value(): a finitef64selected with ties-to-even roundingenclosure(): a dyadic interval containing the exact valueabsolute_error(): the greater distance from the selected value to either enclosure endpoint
Absolute precision uses this input:
AbsoluteBits(bits): limits the enclosure width
upper - lower <= 2^(-bits)
Every u32 value, including zero, is a valid precision. Floating-point selection is independent of the requested precision. Selection normalizes negative zero to positive zero and compares exact values across all finite f64 values, including subnormals, positive zero, and the maximum finite value.
Standalone projection uses the following public values:
project_exact_value_f64: projects one exact valueExactValue: supplies the exact inputProjectionPolicy: supplies the enclosure precisionCertifiedScalarProjection: retains the policy, selected value, enclosure, and absolute error
The result represents a value beyond the finite f64 range with this failure:
ScalarProjectionError::FloatOutOfRange: the exact value is beyond the finite range
Public failures
Failures are separated by operation stage:
GraphError: exhausted IDs, references to nodes yet to be inserted, node cloning, and graph storageInsertError: duplicate IDs, atom-value cloning, and input-map storageEvalError: division by zero, zero powers, even roots, and lower-crate failuresResolveError: missing declarations, unknown IDs, finite range, evaluation, enclosure, and result storageScalarProjectionError: range, lower-crate, and storage failures of standalone projectionStorageError: capacity overflow and allocation refusal with the required total element count
Lower failures and checked copying use these APIs:
std::error::Error::source: references the stored lower failuretry_clone: checks allocation while copying owned sequences
try_clone is the single copying path for types that own sequences.
Configuration and dependencies
Runtime dependencies are the four lower crates:
neco-bigintneco-monomialneco-formsumneco-algnum
The default std feature enables standard error integration and the same feature in the dependencies. Disabling default features selects the core + alloc configuration:
License
MIT License.
ExactComputationProduct
The high-level API preserves the lower-level graph API and assigns exact and numerical responsibilities to the modal-field-projection and Wavesim consumers.
ExactExpressionRequirement: one consumer, its expressions, one typed exact decision, and oneAbsoluteBitsrequirementExactNumericAllocation: exact inputs, exact decisions, numerical operations, descent consumers, and owner-specific numerical error budgets
The six operations form one ownership-moving pipeline:
read_exact_numeric_inputsallocate_exact_numericnormalize_exact_expressionsdecide_exact_propertiesresolve_certified_f64assemble_exact_computation_product
ExactComputationProduct returns one certified bundle for each consumer. Within one owner's expression graph, equal expression-and-precision requests share one exact-to-f64 resolution.
direct_inspection exposes allocations, requirements, typed decisions, certified bundles, and the shared resolution count. It performs no solver, file, process, network, or CLI work.
All high-level failures use the closed NecoFailure family. It preserves the operation, consumer, expression, atom, or decision location and maps storage and lower arithmetic failures. Numerical error budgets remain owned by Modal Field Projection or Wavesim and are not added to CertifiedF64::absolute_error().