Motivation
The lawful-learning manuscript (jcm-sci/lawful-learning) defines a formal taxonomy of
Law-Adherence Metrics (Definition 2.5) and Law-Adherence Diagnostics (Definition 2.6)
that quantify structural constraint satisfaction independently of data-fit accuracy. These are
complementary to the probabilistic scoring rules in ScoringRules.jl (#32): scoring rules
assess distributional calibration, law-adherence metrics assess structural fidelity.
TradeStudy.jl should expose both axes so that Pareto surfaces can span
(accuracy × lawfulness × calibration).
Scope
A LawAdherence submodule providing:
Core metric types
Following the manuscript's Definition 2.5, a law-adherence metric M : H²(D) → R≥0 satisfies:
- Constraint sensitivity — depends on surrogate only through constraint residuals
- Monotonicity — larger violations ⟹ larger metric values
- Interpretability — admits domain-meaningful interpretation
Concrete implementations
| Metric |
Formula |
Notes |
law_adherence_score |
S_law = (1/m) Σ 1[O_i(Ψ) ∈ A_i] |
Proportion of observables in admissible range; soft sigmoid variant for differentiable use |
drift_index |
D = ‖Ψ - Ψ_ref‖ / ‖Ψ_ref‖ |
Relative deviation from lawful reference |
violation_magnitude |
V = Σ_j ‖(H_j[Ψ])₋‖ |
Aggregate constraint violation size |
margin |
M = min_j H_j[Ψ] |
Distance to nearest constraint boundary |
violation_rate |
R = (1/N) Σ 1[∃j: H_j[Ψ(x_n)] < 0] |
Proportion of points with any violation |
elasticity |
E = (x/Y)(∂Y/∂x) |
Signed diagnostic; abs(E) is a metric |
Tier-stratified scoring
law_adherence_score(trial; tier=:all) # aggregate
law_adherence_score(trial; tier=:E) # embedded only (should be 1.0 for PESFs)
law_adherence_score(trial; tier=:P) # penalized
law_adherence_score(trial; tier=:D) # diagnostic
Dynamical-system extensions
| Metric |
Description |
conservation_drift |
Relative change in conserved quantity over horizon |
time_to_violation |
First time any constraint is violated |
violation_duration |
Total time constraints are violated |
stability_fraction |
Proportion of trajectories remaining bounded |
degradation_rate |
Rate of S_law decay under rollout |
Integration with TradeStudy protocols
Dependencies
Non-goals
- This module does not implement PESF training or constraint enforcement —
that belongs in LawfulSurrogates.jl (Phase 5)
- This module only evaluates constraint satisfaction, it does not enforce it
Cross-references
Motivation
The lawful-learning manuscript (jcm-sci/lawful-learning) defines a formal taxonomy of
Law-Adherence Metrics (Definition 2.5) and Law-Adherence Diagnostics (Definition 2.6)
that quantify structural constraint satisfaction independently of data-fit accuracy. These are
complementary to the probabilistic scoring rules in ScoringRules.jl (#32): scoring rules
assess distributional calibration, law-adherence metrics assess structural fidelity.
TradeStudy.jl should expose both axes so that Pareto surfaces can span
(accuracy × lawfulness × calibration).
Scope
A
LawAdherencesubmodule providing:Core metric types
Following the manuscript's Definition 2.5, a law-adherence metric
M : H²(D) → R≥0satisfies:Concrete implementations
law_adherence_scoreS_law = (1/m) Σ 1[O_i(Ψ) ∈ A_i]drift_indexD = ‖Ψ - Ψ_ref‖ / ‖Ψ_ref‖violation_magnitudeV = Σ_j ‖(H_j[Ψ])₋‖marginM = min_j H_j[Ψ]violation_rateR = (1/N) Σ 1[∃j: H_j[Ψ(x_n)] < 0]elasticityE = (x/Y)(∂Y/∂x)abs(E)is a metricTier-stratified scoring
Dynamical-system extensions
conservation_drifttime_to_violationviolation_durationstability_fractiondegradation_rateIntegration with TradeStudy protocols
AbstractScorerprotocol from Scaffold Protocols module: abstract types and core structs #25score()dispatch (score() dispatch: CRPS, WIS, interval, energy, RMSE, MAE #4) should route law-adherence metrics alongside ScoringRules.jl metricsResultsTable(TrialResult and ResultsTable types #2) for Pareto extraction (extract_front() and pareto_rank() via Metaheuristics.jl #8)Dependencies
AbstractScorer,AbstractConstrainttypes)Non-goals
that belongs in
LawfulSurrogates.jl(Phase 5)Cross-references