Skip to main content

Crate phop

Crate phop 

Source
Expand description

§phop

Façade crate for the phop differentiable symbolic-discovery engine, built on the single binary operator eml(x, y) = exp(x) − ln(y).

This crate currently re-exports phop_core (the engine library). It reserves the bare phop name for a forthcoming higher-level façade API.

  • Library: this crate, or phop-core.
  • Command-line tool: install phop-cli, which provides the phop binary (e.g. phop discover data.csv).

Modules§

accel
Accelerator selection for the tensorized EML forward pass.
affine
Affine- and log-affine-leaf EML discovery (M6 root-cause fix, steps 1 + 2).
analyze
Layer D⁺ — post-discovery analysis of a recovered law via the oxieml computer-algebra system.
any_solution
A heterogeneous discovered law — either an EML-tree law from the differentiable core engine or a rich-leaf affine/log-linear law from crate::affine.
codegen
Code generation for discovered EML expressions (Rust, Python/NumPy).
config
Discovery configuration.
dataset
Dataset ingestion: (X, y) pairs from arrays or CSV.
dimension
Buckingham-π dimensional reduction (a discovery prior for phop).
discoverer
The top-level discovery engine.
distill
Layer D — symbolic distillation of a discovered EML tree.
error
Error types for the phop engine.
fit
M1 — gradient-based fitting of the real-valued constants of an EML tree.
forest
Layer A — tensorized EML forest forward evaluation.
gated
Differentiable tree shape via per-node expand/terminate gates (the depth-learning step).
gumbel
Layer B (M2) — differentiable topology via Gumbel-Softmax leaf selection.
loss
Robust regression losses for constant fitting under outliers.
ode
Governing-equation discovery: recover the right-hand side of an autonomous ODE dx/dt = f(x) from a sampled trajectory, using phop as the function learner.
optimize
Library-backed constant refinement via scirs2-optimize.
pareto
Pareto front over (complexity, MSE).
polish
Post-fit refinement of an expression’s constants.
silence
Scoped suppression of process stdout at the file-descriptor level.
solution
A discovered candidate expression and its quality metrics.

Structs§

AffineSolution
A discovered law and its quality.
Analysis
Rendered symbolic analysis of a discovered law (each form simplified, as LaTeX).
Config
Configuration for a crate::Discoverer run.
DataSet
A dataset of input features x (shape [n_rows, n_vars]) and targets y ([n_rows]).
Discoverer
Discovery engine configured by a Config.
Distilled
A discovered expression rendered into every output format phop supports.
EmlTree
EML tree with metadata.
ParetoFront
The non-dominated set of discovered solutions, sorted by complexity ascending.
RootCertificate
Certificate for a verified root-finding result.
Solution
A single discovered expression together with its accuracy and complexity.
Standardizer
Per-column affine transform (value - mean) / std learned from a DataSet.

Enums§

AnySolution
A discovered law from either engine, exposing a common accuracy/complexity interface.
Backend
Compute backend for the expensive numeric inner loops (constant fitting).
EmlNode
EML tree node. All nodes share the same type — uniform binary tree. Arc enables O(1) subtree sharing during symbolic regression.
GpuBackend
A compute backend for the EML forward pass.
PhopError
Errors that can arise during data loading, forest evaluation, or discovery.
RobustLoss
A loss function for fitting an expression’s constants to data.
RootStatus
Status of the root certificate.
ScirsPolish
Which scirs2-optimize algorithm to use for the polish.
TempSchedule
Temperature annealing schedule for the Gumbel-Softmax topology relaxation.

Functions§

analyze
Differentiate, integrate, expand, and take the +∞ limit of tree with respect to variable wrt, rendering each canonical form to LaTeX. series_order is the Maclaurin truncation order.
certified_range
A guaranteed enclosure of the law’s range over an axis-aligned box, via interval arithmetic.
certified_root
Find a certified root of tree in [lo, hi] along variable wrt, with the other variables fixed to others (the wrt slot is overwritten by the search; pass &[] for a single-variable law). Uses oxieml’s interval Newton/Krawczyk verifier; the returned RootCertificate proves unique existence, absence, or indeterminacy within the interval enclosure.
discover_affine
Discover a rich-leaf EML law for (x, y). max_internal bounds eml nodes; cand_cap bounds candidates. Returns the best fit by MSE, or None if x is empty.
discover_affine_pareto
Discover a rich-leaf EML Pareto front (non-dominated over complexity and MSE), sorted by increasing complexity.
discover_auto
Robust “just works” discovery: a meta-ensemble that runs algorithmically diverse searches and returns the merged Pareto front — the best across methods and depths without the caller picking one. It combines phop’s own searches (structural enumeration, Gumbel-Softmax topology, gated depth learning) with the cool-japan oxieml symbolic-regression engine (its GA/beam/MCTS strategies). All oxieml candidates are re-scored with phop’s evaluator so the front is consistent. This is the shape-mixture idea in spirit, and the diversity is something no single monolithic SR algorithm provides.
discover_auto_all
The full meta-ensemble: discover_auto’s EML-tree front merged with the rich-leaf affine engine (crate::discover_affine_pareto) into one Pareto front over both representations.
discover_gated
Discover expressions by differentiable tree-shape search (per-node expand/terminate gates).
discover_gated_warm
Discover by warm-started differentiable tree-shape search: run the cheap enumerate discoverer for a discrete seed, map it onto the gated skeleton, and refine with the gated (depth-learning) optimizer. This is addition.md’s key remedy — seeding the differentiable search from a discrete solution instead of a uniform forest that explores garbage. The seed and the refined trees are merged into one Pareto front, so warm-start never does worse than enumerate.
discover_gumbel
Discover expressions by differentiable Gumbel-Softmax topology search.
discover_ode
Discover the right-hand side f of an autonomous scalar ODE dx/dt = f(x) from a uniformly-sampled trajectory series with timestep dt.
distill
Distill a tree into all supported output formats.
eml_guarded
Guarded EML primitive on graph tensors: eml(a, b) = exp(clip(a)) - ln(clip(b)).
eval_tree
Evaluate an EmlTree forward through autograd over the given data.
fit_constants
Fit the constant leaves of template to ds, returning the fitted tree and its MSE.
gpu_backend
Select the best available forward-eval backend at runtime: CUDA → Metal → wgpu → CPU.
merge_pareto
Pareto-filter a heterogeneous candidate set over (complexity, MSE) — discarding dominated and near-duplicate members — then sort by MSE ascending (most accurate first). Mirrors crate::pareto::ParetoFront::from_candidates but over AnySolution.
mse
Mean-squared error between predictions and targets.
n_constants
Number of free constant leaves in a tree.
pi_groups
Integer basis of the nullspace of the dimension matrix of dims.
polish_constants
Refine the constant leaves of tree against ds with Levenberg–Marquardt (plain MSE).
polish_constants_robust
Refine the constant leaves of tree against ds with a robust Levenberg–Marquardt polish.
polish_constants_scirs
Refine the constant leaves of tree against ds using a scirs2-optimize backend.
snap_constants
Snap each constant to a recognizable clean value — a small integer, a named constant (π, e, √2, …), or a small rational — when the snap keeps the MSE within rel_tol of the unsnapped fit. Constants are snapped one at a time (simplest candidate first), each accepted only if it does not meaningfully worsen the fit, so a constant that genuinely is 1.000… collapses to exactly 1 (removing the ln(1) residue that otherwise defeats exact-equivalence proofs). Returns the snapped tree + MSE.

Type Aliases§

Dimension
Integer exponents over the seven SI base units [s, m, kg, A, K, mol, cd].
Result
Convenience alias for results returned by phop.