Foams, Brains, and AI: When They All Speak the Same Mathematical Language
*— A story of unity, starting from soap bubbles in your bathroom*
---
Have you ever closely observed the foam on a glass of beer?
Dense little bubbles crowded together like noisy neighbors. Decades ago, physicists concluded that foam is like glass—bubbles locked in place, unable to move. This conclusion made it into textbooks, memorized by generations of students.
But it was wrong.
---
1. The Secret Life of Foam
In 2025, engineers at the University of Pennsylvania did something seemingly simple: they used computer simulations to study how bubbles move inside foams.
The results surprised them.
The bubbles never stop moving.
Beneath the seemingly static surface of foam, countless bubbles are constantly rearranging—like people in a crowded room continually adjusting positions to find a more comfortable stance. This motion is not random; it follows a mathematical pattern.
When researchers analyzed this pattern, they discovered something incredible:
The movement of foam bubbles follows exactly the same mathematical rules as the way parameters are adjusted when training modern AI systems.
Let me say it again:
The soap bubbles in your bathroom and the training process of ChatGPT speak the same mathematical language.
---
2. The Wisdom of Being "Flat"
To understand this discovery, we need to talk about how AI learns.
Imagine standing in rugged terrain, trying to find the lowest point—the deepest valley. This is the classic picture of optimization: walk downhill until you reach the bottom.
Early machine learning researchers thought this way. They believed training an AI meant pushing it into the deepest valley to find the "optimal solution."
But modern deep learning tells us: don't do that.
Truly capable AI doesn't trap itself in the deepest valley. Instead, it settles in relatively "flat" regions—where many similar good solutions exist, rather than a single perfect point.
Why? Because flatness means generalization. A model stuck in a steep, narrow valley overfits the training data—it memorizes every example but can't handle new situations. In flat regions, the model learns the "general shape," enabling it to handle situations it has never seen.
Foam bubbles do the same.
They don't pursue a single most stable state; they continuously explore among many viable states. This "not seeking the optimum" strategy is precisely what keeps them stable.
---
3. A Bigger Picture
The similarity between foam and AI hints at something deeper.
Look further:
Bacteria swim through a Petri dish searching for food, sensing chemical concentration gradients through membrane receptors and moving toward favorable directions.
The human brain has roughly 100 billion neurons connected by some 100 trillion synapses. It constantly generates predictions about the world, compares them with actual sensations, and adjusts its internal model.
Evolution explores fitness landscapes over vast timescales, adapting life forms to changing environments.
These seemingly unrelated phenomena—bacterial chemotaxis, brain prediction, evolutionary selection, foam rearrangement, AI learning—may share one underlying principle.
---
4. Free Energy: Nature's Universal Currency
This principle has a name: the Free Energy Principle.
Proposed by Professor Karl Friston of University College London, it states:
> All non-equilibrium steady-state systems—from bacteria to humans, from foam to AI—minimize free energy.
Friston calls it "the most all-encompassing idea since Darwin's theory of natural selection."
What is free energy?
In physics, free energy is a system's energy minus temperature times entropy. In its information-theoretic form, it is an upper bound on "surprise"—a measure of the gap between your expectations and reality.
Imagine walking in a forest, expecting to see a tree, and seeing a person instead. That is "surprise." The free energy principle says biological systems continuously adjust to minimize this surprise.
How? Two ways:
1. Change beliefs (perception): As you approach the "person" and find it's actually a tree, you update your belief.
2. Change the world (action): If it starts raining, you seek shelter, changing the environment to match your belief of "staying dry."
Perception and action are mathematically two sides of the same coin.
---
5. The Bayesian Brain
In the 19th century, German physicist Hermann von Helmholtz proposed a revolutionary idea:
The brain is a statistical inference machine.
We don't "see" the world—we infer it. Our senses receive limited information, and the brain uses it to construct its best guess about reality.
This is the Bayesian brain hypothesis—the brain constantly updates its estimates of the world based on prior knowledge and new sensory evidence.
Modern neuroscience has found supporting evidence:
Repetition suppression: When you repeatedly see the same stimulus, neural responses weaken. Why? Because predictions become more accurate, reducing "surprise."
Mismatch negativity: When stimuli deviate from expectations, the brain produces a characteristic electrical signal—detecting prediction error.
Predictive coding theory holds that the brain works by constantly generating predictions and minimizing prediction errors—exactly the free energy principle as embodied in nervous systems.
---
6. Another Possibility for AI
If the free energy principle is correct, what does it imply for designing AI?
Current deep learning already follows it inadvertently:
- Training = minimizing a loss function (variational free energy)
- Generalization = staying in "flat" regions of solution space
- World model learning ↔ variational free energy minimization
- Exploration–exploitation trade-off ↔ expected free energy minimization
- Friston, K. (2012). A free energy principle for biological systems. *Entropy*, 14(11), 2100-2121.
- Parr, T., Pezzulo, G., & Friston, K. J. (2022). *Active inference: The free energy principle in mind, brain, and behavior*. MIT Press.
- Clark, A. (2015). *Surfing uncertainty: Prediction, action, and the embodied mind*. Oxford University Press.
- Thirumalaiswamy, A., et al. (2025). Slow relaxation and landscape-driven dynamics in viscous ripening foams. *PNAS*.
But we can go further.
Active Inference—a framework built on the free energy principle—offers a different design philosophy:
Instead of simply minimizing a loss function, let the AI actively explore its environment, verifying and correcting its internal model through action.
This has deep connections to reinforcement learning:
Biological intelligence shaped by evolution and artificial intelligence designed by humans converge on the same underlying logic.
---
7. A Paradigm Shift in Our Understanding
The mathematical similarity between foam and AI challenges some deep assumptions.
First: the continuity of life, consciousness, and intelligence.
Tradition treats these as categorically different phenomena. But the free energy principle suggests they form a continuum—from self-organization in physical systems, to adaptation in simple life, to cognition in complex life, to learning in AI—all different expressions of the same principle.
Second: the nature of "understanding."
What is understanding? The free energy principle's answer: the ability to predict.
When you "understand" something, you can accurately predict its behavior. This prediction need not be explicit or symbolic—it can be implicit and distributed, like the weights in a neural network.
Third: determinism versus probability.
Classical science pursues certainty. But life and intelligence are fundamentally probabilistic—they handle uncertainty and make decisions with incomplete information.
Von Neumann foresaw this long ago: > "Information theory consists of two parts: strict information theory and probabilistic information theory. The information theory based on probability and statistics is probably more important for modern computer design."
---
8. Unsolved Mysteries
The free energy principle is not without controversy.
Critics say: it is too abstract to falsify. When you can explain any phenomenon after the fact, your explanation may explain nothing.
Supporters respond: once a state space and generative model are defined for a concrete system, it yields specific testable predictions. In neuroscience and cognitive science, it already has substantial empirical support.
The bigger question:
If everything is free energy minimization, where does "consciousness" fit? What is the "self"? Does "free will" still mean anything?
There are no easy answers. But the free energy principle at least offers a framework for discussing them in a shared language.
---
9. Epiphany in the Bathroom
Back to the foam on that glass of beer.
Next time you shower, watching those soap bubbles, remember: what you're observing may be one of the universe's most fundamental organizing principles.
From foam to bacteria, from brains to AI, these seemingly unrelated systems may all follow one simple rule:
Minimize surprise, maintain steady state, persist.
This isn't magic. It's mathematics.
And mathematics is the universe's only universal language.
---
*"If everything is computation, then physics, biology, economics... all follow the same underlying rules."*
*This may be one of the deepest insights of 21st-century science—or, just a beginning.*
---
Further Reading
*This article was inspired by the 2025 University of Pennsylvania research on the mathematical similarity between foam physics and deep learning, and by Professor Karl Friston's free energy principle framework.*