Thursday March 7 2024.

I was talking to a friend about “mind-body dualism” and started thinking about Mealy machines, a mathematical formalization of systems with input, output, and state (memory). Formally it consists of:

- a set \(S\) of states
- a set \(I\) of inputs
- a set \(O\) of outputs
- a function \(f: S \times I \to S \times O\) where \(\times\) is the Cartesian product.

Given an initial state \(s_0 \in S\) and a sequence of inputs \(i_0,i_1,i_2,...\in I\) a Mealy machine can deterministically produce a sequence of outputs \(o_1,o_2,o_3,... \in O\) and states \(s_1,s_2,s_3,... \in S\) by using the equation \((s_{t+1},o_{t+1}) = f(s_t,i_t)\).

*Note: animation was inspired by this blog post.*

In “mind-body dualism” I imagine there are *two* Mealy machines, hooked up to one another, where one machine is the world, including the body, and other is the mind (doesn’t matter which is which due to symmetry). We observe our senses, process thoughts, take action. Likewise the world “observes” our action, processes it via physics, and “acts” on us by sending us a new observation in an endless cycle… 🌹🪰😊

You could formally define a “**dual system**” (my terminology) to consist of

- four sets: \(S_1,S_2,I_1,I_2\)
- two functions:
- \(f_1: S_1 \times I_1 \to S_1 \times I_2\)
- \(f_2: S_2 \times I_2 \to S_2 \times I_1\)

Thus, \(S_1\) and \(S_2\) are the state sets of the two machines, and \(I_1\) and \(I_2\) are their “interfaces” (input/output and output/input respectively). This is reminiscent of a partially observed Markov decision process, a class of Markov decision process which are commonly used in reinforcement learning.

Next consider multiple agents: define a **multi agent system** with \(n\) agents to consist of

- sets \(S_1, S_2^1, ..., S_2^n, I_1^1, ..., I_1^n, I_2^1, ..., I_2^n\)
- functions:
- \(f_1: S_1 \times \prod_i I_1^i \to S_1 \times \prod_i I_2^i\)
- \(f_2^i: S_2^i \times I_2^i \to S_2^i \times I_1^i\) for each \(i=1,...,n\)

This is like having one central Mealy machine, the environment, hooked up to a bunch of other Mealy machines, the agents. Similar concepts are used in multi-agent reinforcement learning. When \(n=1\), it’s exactly the same as a dual system.

*Theorem (informal)*: any agent in a multi agent system can view themselves being part of a dual system, where all the other agents are part of the environment. See the figure below, where the pink box designates the enlarged environment containing every agent except \(j\), where \(j=1\).

*Theorem (more formal)*: choose an agent \(j\). Then we can turn the multi agent system into a dual system where \(S_1 = S_1 \times \prod_{i \neq j} (S_2^i \times I_1^i \times I_2^i)\), \(S_2 = S_2^j\), \(I_1 = I_1^j\), \(I_2 = I_2^j\), and \(f_2 = f_2^j\). As for \(f_1\), it can be described as follows:

- it takes \((s_1, s_2^1, i_1^1,i_2^1, ..., s_2^{j-1}, i_1^{j-1},i_2^{j-1},s_2^{j+1},i_1^{j+1},i_2^{j+1}, ..., s_2^n,i_1^n,i_2^n)\) and \(i_1^j\) as input
- first it combines \(i_1^j\) with all the other \(i_1\)’s along with \(s_1\) and computes \(f_1\), yielding the new \(s_1\) value along with new \(i_2\) values for all the \(n-1\) agents aside from \(j\).
- each agent \(i\neq j\) is given its new \(i_2\) value, combined with its current state \(s_2\), to produce the new \(s_2\) value and the next \(i_1\).
- thus all the state values have been updated, and it sends the output \(i_2^j\) back to agent \(j\).

**Todo.** What is the philosophical history of this argument, if there’s any? It sounds like something Douglas Hofstadter would say. It also reminds me of the idea of Cartesian framing. It’s pretty naive, but I’m just doing what Lawvere (1992) said:

It is my belief that in the next decade and in the next century the technical advances forged by category theorists will be of value to dialectical philosophy, lending precise form with disputable mathematical models to ancient philosophical distinctions such as general vs. particular, objective vs. subjective, being vs. becoming, space vs. quantity, equality vs. difference, quantitative vs. qualitative etc.

**Categorical systems theory.** You could probably express it like Example 4.60 in polynomial functors book by Spivak. But they use Moore machines instead of Mealy machines, which in their language is a lens \(Sy^S \to Oy^I\). And that means I would have to redraw all the animations.