# Unit Mechanism Learning

> Working title: **Unit Mechanism Learning: From Outcome Prediction to
> Unit-Specific Generation**
>
> Status: foundational arXiv working paper; not submitted.

This directory is the independent scientific source for the foundational Unit
Mechanism Learning paper. The conceptual contract is the fixed-context research
statement on the HCGM entry page:

```text
world: U -> actual realization u* -> Y(x) = f_theta(x,E;u*)
learner: factual predictors x^F -> point / Gaussian / Cauchy abduction about u*
prediction: abducted candidate u + query x^Q -> f_theta(x^Q,E;u)
factual prediction: x^F = x^Q = x
same-token query: keep abduction from x^F fixed; change only x^Q to x'
```

Stability is declared only within the paper's fixed context and time scale.  The
actual modeled token has one fixed embedding realization \(u^\star\); a candidate
\(\widetilde U\sim q_\phi(\,\cdot\mid O)\) is learner-side notation used for
integration or computation.  It is not a new draw of the physical identity and
\(q_\phi\) is not a posterior over response functions.  The current formulation
explicitly adopts injectivity of the unit-to-representation map: different
modeled unit identities have different representations.  This is an
**identity-encoding modeling assumption**, not a coordinate system identified
by one-shot observations; a future framework extension may relax it.  The
downstream map \(u\mapsto\{x\mapsto p_\theta(\cdot\mid x,u)\}\) need not be
injective: distinct representations may induce the same predictive behavior on
the target query domain.

The primary observation regime has one factual event per sampled unit. The
learnable target is therefore the composed conditional prediction
\(p_{\phi,\theta}(y\mid O,x)\), not a uniquely
identified latent coordinate system or a physically true structural equation.
The implementation records `events_per_unit=1` as a protocol invariant rather
than a convenience default.  Alternative-input response curves may exist as
simulator-held oracle truth, but they are never training observations.  Any
future `events_per_unit>1` study is a separate, explicit longitudinal extension and is not a
prerequisite for the one-shot framework.

## Scientific lineage

- `../causal-regression/` is the historical project from which this question
  grew and remains the corrected Causal Regression/provenance workspace. Its
  observed features are abduction evidence, not direct mechanism inputs:
  \(O=X_{\mathrm{obs}}\),
  \(\widetilde U\sim q_\phi(\cdot\mid O)\), and
  \(\widetilde Y=f^{\mathrm{CR}}(\widetilde U,E)\), with
  \(\widetilde U\) interpreted as a learner-side candidate in the predictive
  composition.
- `../learning-discoscm/` is the active flagship paper that places a first
  learnable outcome-mechanism slice inside DiscoSCM causal ontology. This
  directory remains an independent general ML framework paper; neither paper
  inherits the other's theorem or experiment truth.
- `../token-causation/` is the independent causal-ontology / singular-attribution
  paper. It may use this framework as a method lens but does not own this
  paper's theorem or experiment truth.
- The retired `../arxiv-hcgm-regression/` entity is historical provenance
  recoverable through Git, not a current sibling or route.
- `../causal-effect/` and `../continuous-treatment/` are causal
  specializations. Their claims and outputs are not evidence for this paper.
- This directory owns its manuscript, assumptions, implementation, experiments,
  generated tables, and claim ledger.

No historical submission, result table, or frozen implementation is modified
or silently promoted here.

## Owner workface

Before extending the manuscript or launching new runs, read
[`one-shot-protocol.md`](one-shot-protocol.md) first. It records the current
`events_per_unit=1` invariant and explains why the alternative-input oracle is
evaluator-only truth. The checkpoint-hashed `research-workbench.md`,
`claim-register.md`, and `experiment-ledger.md` preserve the earlier planning
state as provenance; their repeated-event ladder is not the current primary
design.

The short `seed.md` remains the stable paper seed. The workbench is the
Chinese-first collaboration surface and may evolve as evidence arrives.

## Main model

The world-side primitive is

\[
Y(x)=f_\theta(x,E;U),\qquad U=u^\star.
\]

For ordinary supervised prediction, the same observed \(X=x\) first acts as
factual evidence \(x^F\) for unit recognition and then as the factual query
\(x^Q=x\). Abduction may be

\[
\widehat u=a_\phi(x^F),\qquad
q_\phi(u\mid x^F)=\mathcal N(\mu_\phi,\Sigma_\phi),\qquad\text{or}\qquad
q_\phi(u\mid x^F)=\operatorname{Cauchy}(m_\phi,\gamma_\phi).
\]

Distributional prediction is written in reader-facing form as

\[
p_{\phi,\theta}(y\mid x^F,x^Q)
=\int p_\theta(y\mid x^Q,u)q_\phi(u\mid x^F)\,du,
\quad p_\theta(\cdot\mid x,u)=\mathcal L_E\{f_\theta(x,E;u)\}.
\]

For a same-token counterfactual, keep \(q_\phi(u\mid x)\) fixed and replace
only \(x^Q=x\) by \(x'\); do not re-abduct from \(x'\). The Cauchy option has
location and scale but no finite mean or variance. Its heavy tails encode
globally open candidate-unit uncertainty, not a guarantee that any unit can
generate any outcome.

The evidence-only branch removes the explicit mechanism query from
\(f_\theta\), while the explicit-input branch retains it.

The current paper's first tractable model deliberately selects the
explicit-input branch:

\[
\mathcal A_\phi(O)=\prod_{j=1}^d
\operatorname{Cauchy}\{m_{U,j}(O),\gamma_j(O)\},
\]

\[
Y(x)=\alpha+\beta^\top x+a^\top U+x^\top B U+\sigma E,
\qquad E\sim\operatorname{Cauchy}(0,1).
\]

It produces a closed-form Cauchy response law without a population prior, KL
term, or latent Monte Carlo estimator.

This Cauchy-bilinear model is not the Causal Regression outcome equation. The
two share abduction-first representation and affine Cauchy propagation, but
the current model adds a direct \(X\to Y\) path and an \(X\)-by-\(U\)
interaction. Treatment semantics form a further specialization and require a
separate identification argument.

### Executable evidence-only special case

At the framework level, Causal Regression is now an executable evidence-only
member rather than only a conceptual lineage statement. The clean-room
`CausalRegressionEvidenceOnlyMechanism` removes the query/direct/interaction
paths and restores the repaired standard-mode latent-wise event-scale law.

Gate 0 passed strict parameter, forward, loss, gradient, Adam-trajectory, and
query-invariance checks. In a 60-fit California replay, its predictions and
distributions matched repaired CausalEngine in all 15 paired cells and it
reproduced the clean-efficiency/severe-shuffle crossover against historical
fixed-scale MLP-Cauchy: -3.71% on clean data, +6.13% at 30% shuffle, and +9.01%
at 40%, with 5/5 severe-condition wins and positive intervals. It did not beat
the learned-scale Direct stress comparator. See
`implementation/GATE0_CAUSAL_REGRESSION_SPECIAL_CASE.md`.

This certificate establishes framework inheritance; it does not make the
explicit-input bilinear specialization identical to Causal Regression or
establish a Unit-factorization advantage.

## Current empirical checkpoint

The observational robustness evidence uses `events_per_unit=1` and `O=X=W`.
Train and validation outcomes are independently deranged within their own
splits at the same ratio; validation is noisy because it selects the training
checkpoint, while test outcomes remain clean. This is an intentional
unit-context/outcome pairing-damage test of one-shot conditional
outcome-generation prediction, not a causal or latent-state identification
experiment.

- Historical V1 is retained only as negative design history because its pooled
  corruption allowed label donors to cross the later train/validation boundary.
- Corrected post-unsealing V2 completes 480 fits and supports a narrow absolute
  direct-Cauchy versus direct-Gaussian clean-test MAE advantage.
- Fresh-seed V3 completes 800 fits and eight multiplicity-controlled contrasts.
  Direct Laplace versus Gaussian is the sole full robust pass; direct Cauchy
  versus Gaussian is absolute-only; no unit-factorization advantage is
  established.

See `implementation/outputs/robust_shuffle_extension_v3_all/extension_v3_report.md`
and `experiment-ledger.md` for the exact gates and provenance.

## Build and checks

```bash
./build.sh
cd implementation
uv sync --extra dev
uv run pytest
uv run python experiments/run_synthetic.py --mode smoke
uv run python experiments/run_ihdp.py --mode smoke --raw-dir /path/to/ihdp/raw
uv run python experiments/run_real_regression.py --mode smoke
uv run python experiments/render_paper_artifacts.py
uv run python scripts/audit_artifacts.py
cd ..
./build.sh
./package-arxiv.sh
```

The final English PDF is copied to:

```text
output/pdf/unit-mechanism-learning-working-paper.pdf
```

The independent Chinese Q&A reading guide keeps `main.tex` and `sections/`
unchanged. Build it with:

```bash
./build-guide.sh
```

Its deployable PDF is copied to:

```text
output/pdf/unit-mechanism-learning-guide-zh.pdf
```

The guide preserves `unit` as an English modeling term and adds section-level
questions about the learnability boundary, the O/X/U/E role split, the closed-form
Cauchy--bilinear mechanism, truth isolation, the V1/V2/V3 protocol history, and
the distinction between absolute error and own-clean degradation evidence.

## Truth boundary

- Synthetic generators may retain oracle response laws in evaluator-only
  objects. Training code receives factual triples only.
- IHDP truth is simulator response-surface truth, not the effect of a real
  person.
- California/UCI results can support factual prediction and calibration only.
- One-shot data do not identify latent coordinates, unit/event scale
  decomposition, or causal counterfactuals without additional assumptions.
- Context Mechanism Learning, repeated-unit identification, non-Cauchy general
  theory, and nonlinear mechanism recovery are deferred.

See `assumption-ledger.md`, `claim-register.md`, and `experiment-ledger.md`
before strengthening any manuscript statement.
