# A frozen geometric hypothesis that can be revised by evidence

**0.10 update:** [PROBLEM_DRIVEN_REVISIONS.md](PROBLEM_DRIVEN_REVISIONS.md) adds an evidence-linked problem agenda, a backward-difference proposal family, explicit measured-force/clock schema branches, and a method to reject a committed proposal when a full replay supplies a counterexample. `problem_cli.py` reuses accepted functions through their active ledgers. A cleared finite queue produces an untested challenge; it never certifies universal mathematical completeness.

**0.9 update:** the large corpus experiment is documented in [CROSS_DOMAIN_STRESS.md](CROSS_DOMAIN_STRESS.md). To inspect the retained hypothesis with the reviewed SVD runtime fix, use `python reality_cli.py status results/reality-ledger-compatible.json`. The original `results/reality-ledger-example.json` retains its old runtime fingerprint deliberately. Running the demonstration below regenerates that example under the installed runtime; do not confuse a regenerated example with the retained compatibility audit.

The user's proposal is implemented as a governed mode for coordinate models. It is not a claim that mathematics already has a universal equation of all experiments, or that this engine has found a physical theory of everything. Mathematics works with definitions, axioms and proofs; physical theories are tested against observations. For example, CERN describes the Standard Model as covering three fundamental forces and explains that gravity is outside that model: [CERN, The Standard Model](https://home.cern/science/physics/standard-model/).

## The constant rule and the revisable equation

For each version v, the engine freezes a coordinate map `F_v` and requires:

```text
R_v(X,Y) = Y - F_v(X)
abs(R_v(X,Y)[j]) <= epsilon[j] for every declared output coordinate j
```

`X` contains the declared observed input coordinates and context. `Y` contains the corresponding observed output coordinates. The coordinate schema, units, domain and absolute tolerances are fixed before the checks. The geometric program and its parameters stay fixed while new in-scope observations remain compatible.

The equation is a **provisional hypothesis**. It may fail. Its test is not a tautology: the observed Y must come from a separate source, not simply from evaluating the same F. Checking a generated output against F is useful for implementation consistency, but provides no new evidence that F describes the outside world. The ledger keeps these two kinds of checks separate.

The fixed error rule is an engineering tolerance, not a complete statistical uncertainty model. Real measurements would require calibrated uncertainty estimates, possibly including correlated input/output uncertainty. This prototype does not perform that uncertainty propagation. See [NIST, Model Verification with Measurement Uncertainty](https://www.nist.gov/publications/model-verification-measurement-uncertainty) for why measurement uncertainty belongs in model verification.

## Enforced behavior

| Event | Engine response |
|---|---|
| New in-scope coordinates agree | Preserve the same equation, coefficients and version |
| An engine-generated result disagrees | Record an internal consistency failure; do not treat it as new observational evidence |
| New in-scope observations disagree | Retain the counterexample and mark the current model contradicted |
| Current model is contradicted | Suspend validated prediction and compilation; allow revision proposals |
| Proposed equation fails old evidence | Reject it without replacing the current version |
| Proposed equation fits retained evidence | Commit its program before requesting new validation coordinates |
| Fresh validation fails | Reject that committed proposal and retain the failed observations |
| Fresh validation passes and replay still passes | Activate the next version; preserve the old version, data and counterexamples |
| A newly accepted version has no counterexample | Freeze it again |
| Same input coordinates have incompatible observed outputs | Flag an observation/context conflict; refuse an automatic deterministic fit |
| New dimensions or out-of-scope coordinates arrive | Record/reject them explicitly; do not silently expand the claim or invent values |

The candidate may use the existing geometric learner, saved-composition search, or a stored nonlinear feature map with a newly fitted affine readout. Searching past evidence can produce a proposal; only a subsequent fresh gate can activate it. If the available families cannot explain the evidence, the engine reports unresolved and retains the contradiction.

Fresh validation coordinates must be distinct and absent from prior recorded inputs. This enforces separation within the ledger; it cannot establish that the caller has never seen those observations, that they are statistically independent, or that their provenance is truthful.

## Compiling the same function

The mode accepts only registered geometric operations and enforces an execution budget. A compiled program can be certified when it is either the identical registered program or has exactly the same polynomial normal form as the current model. A numerically similar fit on a few points is insufficient to certify a different compilation.

`compile_exact` handles supported total polynomial maps. A nonpolynomial model can still be evaluated or certified as an unchanged program; a new nonpolynomial optimization requires an appropriate equivalence method. General-purpose geometry exploration remains available separately through `geometry_cli.py`. The frozen protocol is explicitly entered through `reality_cli.py` or the `RealityLedger` API; it is not a security sandbox that prevents someone from running other Python code.

Hashes record committed equations, the policy and runtime identity. They help catch accidental direct edits and runtime changes; they are not cryptographic proof that observations are true or a tamper-proof audit service.

## Why context and dimensional assumptions matter

If the same X yields two incompatible Y values, possible explanations include an incorrect observation, missing measured context, stochastic behavior, a unit/frame mismatch, or a wrong deterministic model. The ledger detects the conflict; it cannot infer its physical cause merely from the conflict.

Time, control settings, velocities or other measured quantities may need to be part of X. They must be specified as meaningful coordinates. Adding an arbitrary hidden coordinate for every mismatch could fit the data without predicting anything new, so this prototype refuses to do that. Introducing a new external axis requires an explicit schema and evidence migration, including a justified treatment of earlier observations. Internal coordinate lifts and projections remain available within the frozen input/output schema.

Geometric representation alone does not select a unique law. Many equations agree on finite observations. Scope, measurement meaning, complexity limits and new predictions provide additional constraints. This implementation models one deterministic relation per ledger, with fixed coordinate units and a finite scope box; it does not yet support implicit physical field equations, stochastic laws, automatic unit conversion, or manifold/frame discovery.

## What the test demonstrated

The synthetic reference relationship was `x_after = x + z^3`, with y and z unchanged. The engine initially saw only z values -1, 0 and 1. On those observations, `z^3 = z`, so the simpler hypothesis `x_after = x + z` fit every initial point.

New observations at intermediate z values contradicted that simpler equation. The engine:

1. Kept the old equation fixed and recorded a maximum discrepancy of about 0.385.
2. Refused to keep presenting its predictions as validated.
3. Fitted a cubic shear from the retained coordinates using the geometry learner.
4. Kept that candidate inactive until it received 32 fresh coordinate pairs.
5. Activated version 1 after the fresh check and complete replay passed.
6. Predicted another 80 unrecorded coordinate pairs with maximum error below `1.8e-15`.

The fitted cubic coefficient was approximately 1, with rounding-sized coefficients on the lower powers. The fixed tolerance was `1e-8` per output coordinate. This was a controlled synthetic experiment, not a physical discovery.

Twenty-one protocol checks passed, including blocked refits without counterexamples, preserved tolerance/scope, rejected reused validation inputs, rejected fresh validation, retained old evidence, blocked invented dimensions, and runtime-change detection. The checks and example ledger are in `results/reality-ledger-checks.json` and `results/reality-ledger-example.json`.

## Use the governed mode

Run the included demonstration:

```text
python check_reality_ledger.py
python reality_cli.py status results/reality-ledger-example.json
python reality_cli.py compile results/reality-ledger-example.json
```

The `examples/reality-*.json` files provide a complete initial policy, initial equation, initial pairs, counterexamples and fresh validation pairs for a separate reproduction.

For your own measurements, policy JSON specifies `input_axes`, `output_axes`, `scope_min`, `scope_max`, and per-output `absolute_tolerance`. Pair files use the existing `source_points` / `target_points` format.

```text
python reality_cli.py create my-ledger.json policy.json initial-program.json initial-pairs.json --source measurement-batch-1
python reality_cli.py observe my-ledger.json new-pairs.json --source measurement-batch-2 --propose
python reality_cli.py validate my-ledger.json 0 fresh-pairs.json --source measurement-batch-3
python reality_cli.py predict my-ledger.json points.json
python reality_cli.py certify my-ledger.json optimized-program.json
```

Use the returned proposal ID in `validate`; zero in the example is a placeholder for the first proposal. `--propose` can automatically seek a revision after a counterexample, but activation still requires fresh observations. The engine cannot manufacture external evidence for its own equation.
