lawsynth/specs/discovery-run/candidate-contract.md
caelum0x cf7fab2642 feat: estimation + reduction + uncertainty surfacing + TS types
Batch 8 of expansion-v2. Adds the state-estimation and model-reduction control
layers, surfaces coefficient uncertainty in the CLI, and reaches the TS SDK.
Deterministic/offline/std-only (Rust) or typed/tested (TS).

crates/lawsynth-estimate (new): Luenberger observer + steady-state continuous
Kalman filter for discovered linear models, derived as the exact dual of
lawsynth-feedback (place_poles/lqr on (Aᵀ,Cᵀ)). Coupled plant+observer RK4
proves ‖x−x̂‖→0 from a wrong initial estimate reconstructing unmeasured states
from partial measurements; Kalman CARE residual ~4e-16. Observability enforced;
error spectrum verified via koopman::eigen. 33 tests.

crates/lawsynth-modelreduce (new): balanced truncation. Gramians via Kronecker
Lyapunov solve, square-root (Laub) balancing, Hankel-SV truncation with the
2·Σσ a priori bound. HSV analytic match to 1e-12, Lyapunov residual <1e-12,
monotone full-vs-reduced response error, stability preserved. 23 tests.

crates/lawsynth-discovery + lawsynth-cli: `discover --bootstrap N [--confidence
C]` now computes and reports per-coefficient bootstrap CIs + inclusion
probability (text + --json), reusing lawsynth-uncertainty. Hooked in the shared
driver so single-node and partitioned paths agree; content-derived deterministic
seed; default path byte-identical. Closes the gap the docs surfaced. Discovery
41 lib + CLI 101 lib tests.

packages/world-schema + api-client: typed models + runtime parsers mirroring the
engine's stability/control/domains --json exactly (classification strings
confirmed against source + live output). Parsers, not a fabricated HTTP route
(no such endpoint exists). 20 api-client tests + world-schema suite green.

specs/{state-estimation,model-reduction}: boundary specs; discovery-run
candidate contract notes coefficient uncertainty.
2026-08-18 16:36:00 +03:00

1.8 KiB

Candidate contract

DiscoveryResult contains the input DatasetProfile, ordered preprocessing reports, and zero or more retained DiscoveryCandidates. A candidate holds an executable lawsynth_world::World, CandidateMetrics, and an optional bootstrap interval for MSE.

The sparse branch creates one continuous law for every requested state. It uses all dataset columns as feature variables; selected state columns become world states and the others become controls. Coefficients below the configured sparse threshold are omitted, and an all-pruned law becomes the constant zero expression.

When symbolic search is enabled, one affine-calibrated symbolic candidate may be added. Final retention uses pareto_front: a candidate is discarded only when another has no greater MSE and complexity and is strictly better in at least one. Input order among retained candidates is preserved.

Coefficient uncertainty

When a bootstrap is requested (DiscoveryConfig::bootstrap), DiscoveryResult also carries coefficient_uncertainty: one StateCoefficientEnsemble per fitted state, pairing the state's candidate library term names with a per-coefficient percentile confidence interval and inclusion probability from crates/lawsynth-uncertainty (bootstrap_coefficients). The bootstrap resamples the same (Θ, ẋ) used for the point fit, seeded deterministically from the fit content, at the configured coefficient_confidence level (default 0.95). The intervals are bootstrap approximations, not exact frequentist coverage; a small resample count B simply widens them. The field is None on the default (no-bootstrap) path, which stays byte-identical. The discover CLI renders these intervals (--bootstrap N [--confidence C], and --json). See specs/coefficient-uncertainty/ for the underlying method.