The Lagrangian Brain: A Constraint Mechanics of Mind and Machine
Organizations: School of Psychological and Cognitive Sciences, Peking University · IDG/McGovern Institute for Brain Research, Peking University · Peking-Tsinghua Center for Life Sciences, Academy for Advanced Interdisciplinary Studies, Peking University · Center of Quantitative Biology, Peking University ·
Abstract
A brain is in one state at a time, yet most of what decides its next state is absent from it: the patterns its world never produces, the statistics of a lifetime, a goal that lies ahead. In mechanics a wire acts on a bead only through a force that appears when the bead presses on it, and Lagrange computed such forces with one multiplier for each constraint. We propose that a brain follows the same mechanics. Everything a circuit knows, is told or wants is a constraint on its single state and acts through its own multiplier, which accumulates the violation and pushes the state back. Neurons and synapses carry the multipliers, each with its own time constant: inhibitory interneurons carry what never happens, adaptation the cost of staying in one state, synapses the statistics of experience, and feedback to apical dendrites the future. From this hypothesis follow Dale's law, the reciprocal wiring and balance of excitation and inhibition, the paradoxical responses of cortex and the frequencies of brain rhythms. Belief becomes the time one trajectory spends in each state, learning becomes sleep proposing laws and waking refuting the false ones, and planning becomes a wave from the goal meeting a wave from the present. Connectionism and symbolism are the limits of frozen and of instantaneous multipliers, and between them the time a circuit runs becomes the depth of its computation. A machine built on these principles, trained without gradients on 1000 solved puzzles, solves all 422,786 Sudoku-Extreme test puzzles with one trajectory each. It rediscovers the rules of Sudoku by sleeping and waking, plans shortest paths in mazes of 64 times the training area, and tracks permutations exactly on strings 25 times longer than in training, where Transformers fail. A mind, on this view, is life that learns its own constraints.
Figures & tables
| P1 | An interneuron that carries knowledge receives weights proportional, cell by cell, to those it returns; sleep keeps the proportion. | Th. 1 i |
| P2 | An integrating interneuron is silent until its pooled input reaches a fixed level, then holds it there at any drive. | Th. 1 ii |
| P3 | Patterns of interneuron drive that lower the interneurons’ own rates are as many as the unstable excitatory modes. | Th. 1 iii |
| P4 | Slowing the carrier of a band shifts its frequency as ; inhibition lags excitation by about a quarter cycle. | Th. 3 |
| P5 | In rivalry and theta alternation, cumulative dominance imbalance grows less than in a renewal process with equal durations. | Th. 2 i,iv |
| P6 | Synapses onto interneurons potentiate on patterns active in sleep and depress on those active in waking. | Th. 4 i,ii |
| P7 | Over nights of learning a task, reactivations that violate its rules decline to zero, and rule learning then stops. | Th. 4 iv |
| method | grad. | Sudoku | Maze | large | @40 | @1000 |
|---|---|---|---|---|---|---|
| HRM ( Wang et al., 2025 ) | yes | 55.0 | 74.5 | – | – | – |
| TRM ( Jolicoeur-Martineau, 2025 ) | yes | 87.4 | 85.3 | – | – | – |
| PTRM ( Sghaier et al., 2026 ) | yes | 98.75 | 86.73 | – | – | – |
| Transformer, 2 layers | yes | – | – | – | 0.0 | 0.0 |
| Transformer, 6 layers | yes | – | – | – | 14.3 | 0.0 |
| looped, steps | yes | – | – | – | 14.4 | 0.0 |
Appendix figures & tables15 assets
Supplementary material from the paper’s appendix.
Appendix
| constraint | meaning | violation | multiplier and its carrier | time |
|---|---|---|---|---|
| prohibition | a pattern never occurs | , | : an inhibitory interneuron; fast for parvalbumin basket cells, slower and integrating for somatostatin cells and their facilitating synapses | 1–100 ms |
| invariant | a sum never varies | signed : inhibition together with disinhibition | 10 ms–1 s | |
| occupancy | no state lasts forever | : adaptation currents, depression of synapses | 0.1–10 s | |
| the future | a history follows the learned transitions and ends at a goal | dynamics and goal | costate : feedback to the apical dendrites of pyramidal cells | one plan |
| experience | the circuit produces no pattern more often than the world shows it | weight of a synapse onto an interneuron; potentiated in sleep, depressed in waking | hours–days | |
| budget | total activity is limited | a normalization pool; adenosine for energy | ms; hours |
| finding | account | result | |
|---|---|---|---|
| 1 | Dale’s law ( Strata & Harvey, 1999 ) | the multiplier of a prohibition and its weights are nonnegative | Th. 1 i |
| 2 | interneurons inhibit the pyramidal cells that excite them ( Znamenskiy et al., 2024 ) | input and output weights of a multiplier are transposed | Th. 1 i, 4 i |
| 3 | balance of excitation and inhibition in amplitude and tuning ( Wehr & Zador, 2003 ; Okun & Lampl, 2008 ; Xue et al., 2014 ) | complementary slackness | Th. 1 ii |
| 4 | inhibitory plasticity restores balance ( Vogels et al., 2011 ; D’amour & Froemke, 2015 ) | integration of a multiplier | Th. 1 ii |
| 5 | paradoxical responses of cortex stabilized by inhibition ( Ozeki et al., 2009 ; Sanzeni et al., 2020 ) | their number equals the unstable modes held by binding prohibitions | Th. 1 iii |
| 6 | divisive normalization ( Heeger, 1992 ; Carandini & Heeger, 2012 ) | the multiplier of a budget on activity | Eq. ( 3 ) |
| experiment | claim | task | learned from | main result |
|---|---|---|---|---|
| 1 laws from dreams (§ G.2 ) | sleep proposes laws and waking refutes the false ones (Th. 4 ) | worlds with hidden forbidden pairs and triples; the rules of Sudoku | 1000 lawful states, no counterexamples | every hidden law recovered; all 243 invariants and 7290 prohibitions of Sudoku recovered by sleep, waking and consolidation |
| 2 thinking on Sudoku (§ G.3 ) | no rest on an error, exact rest at a solution (Th. 1 , 2 ) | Sudoku-Extreme, all 422,786 test puzzles | solutions of 1000 training puzzles, by counting | every test puzzle, one trajectory each; ablations; laws learned apart compose |
| 3 planning in mazes (§ G.4 ) | a goal acts through a costate (Th. 6 , 7 ) | Maze-Hard; perfect mazes up to | a preference among directions fitted on 1000 training mazes | shortest paths in 100.0% of test mazes and in 100.0% of mazes with 64 times the area; a law without a costate plans none |
| 4 state tracking (§ G.5 ) | a law has no size, and time is depth (Th. 5 , 6 ) | word problems of , , , | 10,000 strings of length at most 40 | exact at length 1000 on every group; on , Transformers exact on no string of length 100 or more |
| 5 circuit signatures (§ G.6 ) | paradoxical count; balanced rivalry (Th. 1 iii, 2 ) | simulated circuits stabilized by inhibition; rivalry | nothing | the count holds in 200/200 circuits; rivalry as variable as in humans and balanced over minutes |
| World | Laws | Recovered | False | Unseen | Forbidden (%) | Predicted (%) |
| (a) planted , , world 0 | 9 | 9 | 0 | 0 | 0.00 | 0.01 |
| (a) planted , , world 1 | 9 | 9 | 0 | 0 | 0.00 | 0.01 |
| (a) planted , , world 2 | 9 | 9 | 0 | 0 | 0.00 | 0.03 |
| (a) planted , , world 0 | 18 | 18 | 0 | 0 | 0.00 | 0.12 |
| (a) planted , , world 1 | 18 | 18 | 2 | 2 | 0.44 | 1.06 |
| (a) planted , , world 2 | 18 | 18 | 0 | 0 | 0.00 | 0.17 |
| Run | Solved | Wrong stop | Unresolved | Median updates | |
|---|---|---|---|---|---|
| Multiplier network (seed 0) | 1000 | 100.0 | 0.0 | 0.0 | 44626 |
| Multiplier network (seed 1) | 1000 | 100.0 | 0.0 | 0.0 | 50046 |
| Multiplier network (seed 2) | 1000 | 100.0 | 0.0 | 0.0 | 46174 |
| Multiplier network (seed 3) | 1000 | 100.0 | 0.0 | 0.0 | 48027 |
| Invariant multipliers only (seed 0) | 1000 | 91.8 | 0.0 | 8.2 | 172685 |
| Pair multipliers only (seed 0) | 1000 | 62.5 | 36.2 | 1.3 | 95253 |
| Exclusions | True invariants | Spurious | Prohibitions | Provisional | Solved (%) | Seconds | |
|---|---|---|---|---|---|---|---|
| 75 | 105450 | 243 | 6 | 7330 | 98120 | 79.3 | 285.3 |
| 100 | 79596 | 243 | 0 | 7290 | 72306 | same | 5.2 |
| 150 | 46631 | 243 | 0 | 7290 | 39341 | same | 0.3 |
| 200 | 28258 | 243 | 0 | 7290 | 20968 | same | 0.1 |
| 500 | 7771 | 243 | 0 | 7290 | 481 | same | 0.2 |
| 1000 | 7293 | 243 | 0 | 7290 | 3 | same | 0.6 |
| Source | Solved (%) | Median updates | Largest | |
|---|---|---|---|---|
| all sources | 422786 | 100.0 | 49610 | 3076726 |
| 01_file1 | 93552 | 100.0 | 82940 | 2347830 |
| puzzles0_kaggle | 9954 | 100.0 | 1504 | 2940 |
| puzzles1_unbiased | 99749 | 100.0 | 7840 | 137368 |
| puzzles2_17_clue | 4855 | 100.0 | 27776 | 577152 |
| puzzles3_magictour_top1465 | 143 | 100.0 | 29232 | 173696 |
| Condition | Valid | Shortest | Exact | |
|---|---|---|---|---|
| Maze-Hard , test | 1000 | 100.0 | 100.0 | 100.0 |
| perfect mazes | 100 | 100.0 | 100.0 | – |
| perfect mazes | 100 | 100.0 | 100.0 | – |
| perfect mazes | 100 | 100.0 | 100.0 | – |
| Maze-Hard, law without costate | 1000 | 0.0 | 0.0 | – |
| Group | Length | Law | TF-2 | TF-6 | Loop | Loop | LSTM |
|---|---|---|---|---|---|---|---|
| Z2 | 40 | 100.0 | 0.0 | 1.0 | 0.1 | 14.8 | 100.0 |
| Z2 | 100 | 100.0 | 0.0 | 0.0 | 0.0 | 0.3 | 100.0 |
| Z2 | 500 | 100.0 | 0.0 | 0.0 | 0.0 | 0.0 | 100.0 |
| Z2 | 1000 | 100.0 | 0.0 | 0.0 | 0.0 | 0.0 | 100.0 |
| Z5 | 40 | 100.0 | 70.9 | 72.3 | 71.9 | 73.6 | 100.0 |
| Z5 | 100 | 100.0 | 0.0 | 0.0 | 0.0 | 0.1 | 100.0 |
| Check | Result |
|---|---|
| Simulated circuits whose paradoxical count equals their unstable modes | 200/200 |
| Simulated circuits that settle back after a perturbation | 200/200 |
| Largest deviation of a simulated response from the theory (relative) | 0.021 |
| Mean dominance duration (s) | 2.55 |
| Coefficient of variation of dominance durations | 0.547 |
| Imbalance power below 0.05 Hz, relative to renewal | 0.024 |
Computational Cognitive Modeling
Computational cognitive modeling uses formal models and simulations to explain how people perceive, learn, remember, reason, and choose.
See all 135 papers