A mathematical framework for psychedelic effects using double category theory and predictive coding.
Read docs/limitations.md before citing anything here. Several of this project's original headline claims did not survive audit. The model has one fitted parameter, not zero; it does not beat a constant baseline out of sample; and its categorical novelty claim has been retracted. What does hold up is documented below, with the evidence for and against kept side by side.
| Page | What it covers |
|---|---|
| docs/mathematics.md | Curvature, sheaves, equipment, laxators — what each buys and where it stops |
| docs/parameters.md | Every constant: measured, estimated, fitted, or assumed |
| docs/validation.md | How claims are tested and how to read the output |
| docs/limitations.md | Consolidated negative results and open problems |
| docs/audit.md | What was wrong before, what changed, which numbers moved |
Dose → Hill equation (EC50) → receptor occupancy O
→ Black-Leff model (ε from assays) → coupling efficiency κ
→ Signal λ = α × κ × O × receptor_weight
→ Ego dissolution = 1 - exp(-λ)
| Drug | Model | Empirical | 95% CI | EC50 source |
|---|---|---|---|---|
| Psilocybin 25mg | 0.65 | 0.68 ± 0.09 | [0.50, 0.86] ✓ | PET (Madsen 2019) |
| LSD 100μg | 0.67 | 0.65 ± 0.12 | [0.41, 0.89] ✓ | PET (Holze 2021) |
| DMT 30mg | 0.73 | 0.75 ± 0.15 | [0.46, 1.04] ✓ | estimate |
| 5-MeO-DMT 15mg | 0.75 | 0.85 ± 0.12 | [0.61, 1.09] ✓ | estimate |
| Mescaline 300mg | 0.37 | 0.60 ± 0.15 | [0.31, 0.89] ✓ | estimate |
| Ayahuasca 50mg | 0.72 | 0.70 ± 0.12 | [0.46, 0.94] ✓ | estimate |
How strong is this? Two things have to be said together, and the second is the one that carries weight:
- 6/6 within 95% CI, but that is a weak test. The empirical CIs are wide (n is small; SDs are 0.09–0.15). A predictor that ignores drug and dose entirely and always answers 0.70 also scores 6/6 — in fact 24 different constants do. Containment alone does not distinguish this model from a constant, and should not be quoted as though it did.
- The model orders the drugs correctly (Spearman ρ = 0.94, p = 0.005),
which no constant predictor can do. This is the strongest positive result,
and it is what
run_baseline_comparison()exists to keep visible. - But out of sample it does not beat that constant. Leave-one-out log-likelihood is 5.486 for the biophysical model against 5.410 for a fitted constant — a 0.08 nat gap over six points, which is a tie. It wins on 5-MeO-DMT (the only model that predicts the outlier) and loses exactly as much on mescaline. It does beat a dose-only logistic by 2.94 nats, so milligram dose alone is not carrying the fit — but on present data neither is the receptor pharmacology. Six compounds cannot settle this; see docs/validation.md.
On "zero parameters". The scale factor α = 2.279 is fitted, calibrated on
psilocybin 25 mg and then held fixed across the other five drugs. The a-priori
biophysical derivation gives α ≈ 3.85; the gap used to be concealed by an
undocumented +1 inside a logarithm. So this is a one-parameter model with
five out-of-sample predictions, which is a defensible claim, rather than a
zero-parameter model, which was not.
On EC50 provenance. Only psilocybin and LSD have PET-derived EC50s. The
other four are estimates from human dose-response literature and are labelled
as such in DrugProfile.ec50_source. Earlier versions let all four silently
inherit psilocybin's placeholder, which scored mescaline's 300 mg dose against a
15 mg EC50 — wrong by more than an order of magnitude.
Limitations: overpredicts at sub-therapeutic doses (exponential approximation); mescaline is the weakest fit and sits near the bottom of its interval.
python3 -c "from src.validation.core import run_baseline_comparison as r; r()"from src.core import create_cortical_hierarchy
from src.pharmacology import PsychedelicFunctor, DRUG_PROFILES, compute_ego_dissolution
# Apply psilocybin to cortical hierarchy
hierarchy = create_cortical_hierarchy(n_levels=6)
functor = PsychedelicFunctor(DRUG_PROFILES['psilocybin'])
transformed = functor(hierarchy, dose=0.7, time_minutes=90)
ego = compute_ego_dissolution(transformed, hierarchy)
print(f"Ego dissolution: {ego:.2f}") # 0.86 at this abstract doseNote that dose=0.7 here is on the simulation's unitless 0–1 scale, not a
milligram dose, so it is not comparable to the table above. For dose-in-mg
predictions use compute_ego_dissolution_biophysical('psilocybin', 25.0).
python3 -m src.validation.core # Full-dose validation
python3 -m src.validation.microdose # Microdose validation
python3 -m pytest tests/ # Category laws and validation-suite testsPsychedelics change the rules, not the wiring.
The framework models three levels of structure:
- 0-cells: Cortical levels (V1 → V2 → V4 → IT → PFC → Self) - unchanged
- 1-cells: Prediction/error channels between levels - unchanged
- 2-cells: Precision-weighted update rules - transformed by psychedelics
The self emerges from compositional coherence: coherent composition of 2-cells across the hierarchy. Ego dissolution occurs when graded precision reduction disrupts this coherence.
Key discriminator: uniform precision reduction (sedatives) leaves composition intact → sedation. Graded reduction (psychedelics) breaks it → ego dissolution.
Two metrics track this, and they are not equally good evidence:
| Metric | What it is | Status |
|---|---|---|
| Γ (compositional coherence) | 1/(1+CV) over per-level precision factors |
Dispersion statistic. Uniform factors give Γ = 1 by construction, so Γ cannot fail to show the discriminator. |
| V (interchange violation) | Genuine two-path composition defect | Derived from the update rule, so it can fail. Use this one. |
For V, the discriminator is a theorem rather than a definition: both
composition paths are affine in the state with prediction weight
w(π) = π/(π+1), so they agree exactly when adjacent levels share precision
and diverge as the gradient steepens.
| Dose | V (graded) | V (uniform) |
|---|---|---|
| 0.0 | 0.257 | 0.257 |
| 0.5 | 0.212 | 0.278 |
| 1.0 | 0.394 | 0.278 |
Graded reduction raises V above the uniform case at higher doses. The dip at low dose is real and worth stating: the baseline hierarchy already carries a precision gradient, and low doses flatten it before steepening it.
The categorical apparatus was originally decorative: every quantity was computed and then immediately normed, and a norm forgets everything, so nothing survived to make contact with data. These modules keep the structure.
The two composition directions make the hierarchy a lattice in level × time. The interchange defect on a plaquette is a commutator, i.e. a discrete curvature:
F(i, t) = I_i ∘ U_i^t − U_{i+1}^t ∘ I_i
Kept as an operator rather than a magnitude, it gives three things a scalar cannot. Composition: the defect over a composite region is determined exactly by the plaquette curvatures it encloses, each transported by the surrounding maps —
D = F(t₂) ∘ U^{t₁} + U^{t₂} ∘ F(t₁) (time)
D = I_{i+1} ∘ F(i) + F(i+1) ∘ I_i (levels)
Both hold to machine precision (residual < 1e-15), so local measurements determine global order effects with no free parameters. Direction: the predicted order effect is a specific vector, so an experiment can project a measured ERP difference onto it rather than compare two magnitudes. Eigenstructure: which representational directions decouple — but see the negative result below.
Levels carry belief spaces, channels carry restriction maps, and the hierarchy becomes a cellular sheaf. A global section is a unified self-model, and precision-weighted predictive coding is identical with gradient flow on the sheaf Dirichlet energy — verified numerically, cosine 1.000, not an analogy:
E(μ) = ½ Σ π_ij ‖F_i μ_i − F_j μ_j‖² , μ̇ = −Lμ
Ego dissolution is the collapse of the spectral gap of L: binding strength
falls monotonically 0.475 → 0.231 from zero to full dose. This is measurable
from neural covariance rather than from a questionnaire.
Prediction and error are an adjoint pair (companion/conjoint), so the
framework is a proarrow equipment. The triangle identities are exact when
E = pinv(P) and their residual predicts failure of belief updating to
converge. This fixed a real defect: create_cortical_hierarchy drew the
top-down and bottom-up weights independently, giving a "hierarchy" whose
two directions were unrelated — not inference. It now builds an isometric
generative map with its adjoint (adjoint_channels=True).
Leave-one-out log-likelihood against nested nulls, replacing CI containment. Alpha is genuinely refitted per fold.
Kept here deliberately, because the earlier validation suite reported 28 matches and 0 mismatches — it counted seven branches that were hardcoded to pass, and several comparisons that never consulted the model at all. These are what the corrected suite finds.
The four that matter most:
- The model does not beat a constant out of sample. Leave-one-out log-likelihood: biophysical 5.486, constant 5.410. A gap of +0.08 nats over six points is a tie, and the sign of a gap that small carries no information. The model wins big on 5-MeO-DMT (1.05 vs 0.16 — it is the only model that predicts the high outlier at all) and gives it all back on mescaline (−0.02 vs 0.67), which is one of the four estimated-EC50 drugs. Net: wash. It does beat a dose-only logistic by 2.94 nats, so milligram dose alone is not what carries the fit — but neither is the pharmacology, yet.
- Scalar precision carries no directional information. The curvature's
linear part is
(w_{i+1} − w_i)·M, a scalar multiple of the interface, so its singular directions are identical for every drug and every dose (nonproportionality exactly 0.0). Claims about predicting phenomenological content are unsupported in this regime. Matrix-valued precision restores it (nonproportionality 0.83–0.99), which is whatMatrixPrecisionTwoCellis for. The line that destroys it isnp.trace(precision)/len(precision). - The psychedelic functor is exactly strict, so the drug has no
compositional signature. Its laxators are identically zero — not small,
exactly zero — because the precision factor depends only on level index and
is applied factorwise. A strict functor cannot distinguish one drug from
another, or a drug from placebo, at the level of composition. Zero bits.
StateDependentFunctor(occupancy tracking ongoing activity) is genuinely lax and does give drug-specific signatures that differ in shape, not just potency. - The chain topology makes the cohomological story vacuous. On a path graph H¹ = 0 and H⁰ has exactly one stalk's dimension: a global section always exists and is freely determined by any single level. There is no obstruction for ego dissolution to destroy. Cycles are needed — from lateral connections or the temporal direction — and the framework lists lateral connections as a limitation. They are in fact a precondition.
The rest:
- The ablation test fails. Removing the hierarchy entirely (flat precision
reduction,
flatinrun_ablations()) predicts ego dissolution 0.500 against the full model's 0.495, with the empirical target at 0.510. On this scalar, the hierarchical structure is not doing measurable work. It does show up in V, which flat reduction leaves unchanged — so the right reading is that ego-dissolution magnitude alone is too coarse a target to test the structure, not that the structure is vindicated. - CI containment does not discriminate. See the baseline comparison above.
- The interchange law does not hold even at baseline. A generic hierarchy has a precision gradient, so V > 0 before any drug is applied. The claim the model can support is about the change in V with dose, not about baseline commutation.
- The interchange prediction only holds at the top of the hierarchy.
Violation rises under psilocybin for level pairs 2→3, 3→4 and 4→5, and
falls for 0→1 and 1→2. The framework predicts an increase "particularly at
high hierarchical levels", so the high-level rise is a hit, but the
low-level decrease is not predicted by anything and stands as a partial
mismatch.
run_all_critical_tests()now prints the whole gradient rather than a single level pair, since picking one pair can produce either verdict. - One comparison is scored as untested, not matched. Tagliazucchi 2016
reports r = +0.57 on a global-connectivity measure; the model predicts a
negative r for DMN integrity. These are different measures, so the
comparison is recorded as
NOT TESTEDrather than counted as agreement. - The DMN-ego correlation was a single simulated study. Across 200
simulated 15-subject studies the model gives r = −0.38 ± 0.23, spanning
[−0.75, +0.07]. 6% of studies that size return a positive correlation,
which this project's own falsification criteria score as refuting the model.
Quoting one seed's −0.40 as a "quantitative match" to the empirical −0.49
was choosing a draw, not reporting a prediction.
get_model_predictionsnow returns the ensemble mean and its spread.
src.theory.lens_comparison tests the paper's stated basis for novelty
(paper.tex ~1036): "in lens formulations, forward and backward passes are
coupled; decoupling requires additional structure."
It is false, and the framework's own type signature shows why.
TwoCell.__call__(prediction, error_below, error_above, current_state) is a
lens put : S × A' → S — the same data, not an analogy. KalmanTwoCell never
reads current_state, so it is already a decoupled put sitting inside the
framework; PrecisionWeightedTwoCell does read it, and is exactly the
"coupled" lens the claim objects to. A put may ignore s, so decoupling
needs no additional structure at all.
What is real: the translation is not faithful.
PrecisionWeightedTwoCell(π) and VariationalTwoCell(π, η=1/(π+1)) are the
same function of (state, feedback) — gap 7e-16 — but the functor separates
them (gap 2.52 after transform_precision). So the double category does see
something a bare lens does not. That distinction is precisely the Para
construction: what differs is parameterization by precision, and Ψ is
reparameterization. ParaLens recovers it in ~15 lines. This is
Para(Lens) from Cruttwell–Gavranović–Ghani–Wilson–Zanasi, published before
this paper.
The paper already concedes this in an adjacent remark ("a difference in directness rather than fundamental capability"), so it currently contradicts itself and the stronger claim is the wrong one. It costs nothing to drop: the precision-gradient hypothesis and the six-compound ordering are the actual contribution and do not depend on the formalism being new.
| Prediction | Model | Empirical | Source |
|---|---|---|---|
| DMN-Ego correlation | r = -0.40 | r = -0.49 | Carhart-Harris 2016 |
| Connectivity decrease | -19% | -25% | Siegel 2024 |
| Entropy increase | level-dependent (ρ = 1.0) | confirmed | Schartner 2017 |
The connectivity and entropy figures used to be hardcoded literals (−0.22 and 0.96) presented as model output and compared against empirical values — a constant compared to a constant. Both are now derived from the transformed hierarchy, which is why connectivity moved to −19% and now underpredicts.
Cross-frequency coupling gradient: PAC reduction follows hierarchy:
| Region | Predicted | Empirical |
|---|---|---|
| Occipital | 15% | 15% ✓ |
| Parietal | 24% | 25% ✓ |
| Prefrontal | 40% | 35% ✓ |
5-HT1A/2A valence prediction: Higher ratio → more positive:
| Drug | Predicted | Empirical |
|---|---|---|
| LSD | 65% | 65% ✓ |
| Psilocybin | 70% | 75% ✓ |
| 5-MeO-DMT | 88% | 80% ✓ |
More Validation Details
MEQ Validation (OpenNeuro ds006072)
Model prediction 0.66 vs empirical 0.68 ± 0.09 - within measurement uncertainty.
| Subscale | Psilocybin | Control | p-value |
|---|---|---|---|
| Mystical | 0.68 | 0.10 | 0.011* |
| Transcendence | 0.79 | 0.06 | 0.003* |
| Positive mood | 0.74 | 0.21 | 0.002* |
Φ Channel Capacity Test*
| Condition | Φ* | Hierarchy Asymmetry |
|---|---|---|
| Placebo | -0.23 | 0.00 (top-down) |
| 2-Cell Transform | -0.23 (preserved) | -0.01 (flattened) ✓ |
| Precision Reduction | ↓ decreased | unchanged ✗ |
Psychedelics change HOW information flows (2-cell transformation), not HOW MUCH (Φ* preserved).
Erowid Content Analysis (371 reports)
| Prediction | Effect | Match |
|---|---|---|
| DMT > LSD entity content | +95% | ✓ |
| LSD > Mushrooms cognitive meaning | +9% | ✓ |
| DMT > LSD mystical meaning | +200% | ✓ |
σ1 → mystical meaning; D2 → cognitive meaning.
Sub-perceptual doses operate between two thresholds:
- Plasticity threshold (~5μg LSD) → TrkB/mTOR activation, BDNF release
- Perceptual threshold (~25μg LSD) → acute psychedelic effects
| Prediction | Model | Empirical | Source |
|---|---|---|---|
| BDNF increase | 35% | 35% | Hutten 2021 ✓ |
| DMN reduction | -12% | -15% | Murray 2022 ✓ |
| Cognitive battery | ~0 | null | Cavanna 2022 ✓ |
| Ego dissolution | 0 | 0 | Multiple ✓ |
from src.microdose import MicrodoseProtocol, MicrodoseSchedule, simulate_microdose_protocol
protocol = MicrodoseProtocol(drug='lsd', dose_ug=10.0,
schedule=MicrodoseSchedule.FADIMAN, duration_weeks=4)
results = simulate_microdose_protocol(protocol)The framework predicts phenomenological content via attractor dynamics:
| Content Type | Mechanism |
|---|---|
| Geometric hallucinations | V1 periodic attractors (cortical architecture) |
| Entity encounters | IT face-selective attractors (deep wells) |
| Ego dissolution | Escape from highest-level self-attractor |
| Mystical unity | Global distributed attractor (wide basin) |
| Component | Module | Description |
|---|---|---|
| Double Category | src.core |
0-cells, 1-cells, 2-cells, composition |
| Curvature | src.core.curvature |
Interchange defect as an operator; cocycle laws |
| Sheaf | src.core.sheaf |
Self as global section; Laplacian spectral gap |
| Equipment | src.core.equipment |
Prediction/error adjunction, triangle identities |
| Psychedelic Functor | src.pharmacology |
Receptor binding → 2-cell transformations |
| Laxators | src.pharmacology.laxator |
Drug signature as failure of strictness |
| Biophysical Parameters | src.theory.biophysical |
Parameter derivation; one fitted scale |
| Lens comparison | src.theory.lens_comparison |
Test of the novelty claim (it fails) |
| Model comparison | src.analysis.model_comparison |
LOO log-likelihood vs nested nulls |
| Attractor Dynamics | src.simulation.attractors |
Content prediction via Kramers escape |
| Microdosing | src.microdose |
Fadiman/Stamets protocols, plasticity |
Full Module Reference
Core
src.core- Double category, hierarchy, coherencesrc.pharmacology- Drug profiles, functor, receptor interactionssrc.theory.biophysical- Parameter derivation chain
Validation
src.validation.core- Empirical validationsrc.validation.phi_star- Φ* channel capacity testsrc.validation.critical_tests- Falsification criteria
Simulation
src.simulation.dynamics- Message passing, belief updatingsrc.simulation.attractors- Content prediction
| Criterion | Falsified if |
|---|---|
| DMN-ego correlation | r > 0 or |r| < 0.15 (p < 0.01) |
| Uniform reduction | GABAergic agent (<20% gradient) causes ED >50% of psilocybin |
| Coherence-dissolution | Cross-level coherence r > -0.2 with ego dissolution |
| Drug ordering | Model fails to rank ego dissolution across drugs better than chance |
| Interchange gradient | V does not rise with dose under graded reduction |
Note on the first criterion: the model's own simulation returns a positive r in 6% of 15-subject studies, so a single study of that size cannot apply this criterion in either direction. Any test of it needs either a larger sample or a pre-registered ensemble.
Run python3 -m pytest tests/ for the structural criteria: the double category's
composition must be associative and unital, and verify_interchange_law must
report a nonzero defect on a graded hierarchy. An earlier version of that
function compared an expression against itself and so returned zero violation
for every possible model — test_interchange_law_is_not_vacuous guards against
that regression specifically.
| Dataset | Description |
|---|---|
| ds006072 | Psilocybin precision mapping |
| ds003059 | LSD fMRI + ego dissolution |
| ds006110 | PsiConnect multimodal |
- Carhart-Harris et al. (2016) Neural correlates of the LSD experience. PNAS
- Siegel et al. (2024) Psilocybin desynchronizes the human brain. Nature
- Carhart-Harris & Friston (2019) REBUS and the anarchic brain. Pharmacol Rev
- Hutten et al. (2021) Low doses of LSD acutely increase BDNF. ACS Pharmacol. Transl. Sci.
@article{singh2025algebra,
title={The Algebra of Ego Death: Double Categories, Predictive Coding,
and the Mathematics of Psychedelic Phenomenology},
author={Singh, Rishabh},
year={2025}
}MIT



