1 Introduction

It is known that the universal Turing machine models any classical computation performed by any classical computer. At the same time, the Turing machine is very simple from the point of view of its structure and operations it performs. In the realm of intelligent behaviour of living (unicellular as well as multi-cellular) organisms, we can search for some underlying universal computational phenomena, which presumably would be represented by a highly simplified living organism. In other words, we can try to define some artificial (i.e. simplified) living organisms as a universal machine like the Turing one. In this paper, we aim to sketch a universal logical model for simulating the intelligent behaviour of living organisms.

This behaviour is usually presented as a multi-agent system where each particle (computational unit or ‘agent’) has an individual program within the whole programmable behaviour. For instance, even a one-cellular organism is regarded as a multi-agent computational system [1]. There are two main types of biological objects recently discovered from the point of view of computational theory: (i) unicellular organisms with their abilities to solve some computational problems such as planar-geometric or graph-theoretic ones (bacterial colonies [2], Physarum polycephalum [3], Amoeba proteus [4], etc.); (ii) different swarms with their abilities to solve, first of all, logistic problems (ant colonies [5], bee colonies [6], fish schooling [7], bird flocking and horse herding [8], etc.). The point is that some real-time experiments with unicellular organisms as well as with swarms are easy to be performed for constructing appropriate computational samples. On the other hand, their behaviour can be managed by external stimuli to the same extent. Evidently that different organisms have different stimuli attracting and repelling their activity, but mathematically we deal with the same topological space we are going to define in this paper – namely, we consider a mathematical model how active particles react to the stimuli located differently.

Hence, we focus on many biological agents (ants, bees, active particles of Physarum polycephalum and Amoeba proteus, etc.) concurrently reacting to a set of external stimuli located variously and with different powers of intensity. This study is scale invariant. The matter is that the scale of stimuli for unicellular organisms differs a lot, for example, from the scale of stimuli for swarm mammals (such as rats), but topologically both situations are the same: some stimuli scattered around the individuals cause their concurrent reactions to these stimuli.

The multi-agent intelligent behaviour of unicellular amoeboid organisms (e.g. Physarum polycephalum and Amoeba proteus) is explained by a polymerisation and depolymerisation of actin filaments – short protein tubes combined among themselves and responsible for changing the cell shape. These actin filaments can appear and disappear and they can be collected into different complex forms from bushes to trees. It depends on external stimuli which cause the polymerisation or depolymerisation of new actin filaments. So, such intelligent reactions of one cell to its environment are explained by actin filament networks. Consequently, these networks can be examined as a medium implementing different logical and arithmetic functions [4, 9,10,11]. Hence, each actin filament may be regarded as a computational unit (particle or ‘agent’) within an appropriate network. Meanwhile, the actin filament networks have some effects of neural networks such as lateral activation and lateral inhibition [4].

So, in our paper, we present the approach showing that each multi-agent living system such as Physarum polycephalum or a swarm in some sense represents universal computational phenomena which usually are typical for more complicated, neural networks. We demonstrate that the space orientation of Physarum polycephalum or a swarm reflects the mechanism of activation of agents/particles/units – e.g. (i) actin filaments in a cell; (ii) neurons in a hippocampus of brain; (iii) swarm members like ants or bees. In this case one assigns a stimuli space X to a subspace \({\mathcal {N}}_X\) of active units (actin filaments, neurons or swarm members) which are sensitive to the external stimuli from X and react by their excitation (activation). In the case of swarms, the activation of their members means that they are located on some traces connecting food pieces to the nest.

External stimuli are linked to computational units (actin filaments, neurons or swarm members) via some codes which are the patterns of excitation typically grouped to comprise words representing binary sequences of 0, 1 where 1 at the i-th place means that the i-th unit from \({\mathcal {N}}_X\) has been activated (the spike). Even though the space of stimuli X is considered as a kind of discrete topological space we extend it to a subset \(X\subset {\mathbb {R}}^d, d\in {\mathbb {N}}\setminus \{0\}\) thus endowing it with the certain open convex in \({\mathbb {R}}^d\) subsets \(\{U_i \}_{i\in I}\), \(\bigcup _{i\in I}U_i=X\), as its cover. The index set I is finite at this stage, though in some next sections we will consider also an infinite extension. The open convex subsets \(U_i\) can be also determined as domains of the so-called receptive fields (RFs). A RF on X is a function \(f_i:X\rightarrow {\mathbb {R}}_{\ge 0}, i\in I\) assigning to a stimulus \(f\in X\) a non-negative number which expresses how the i-th unit from \({\mathcal {N}}_X\) is likely to fire in the presence of the stimulus f. Given another stimulus \(g\in X\), we have another RF, i.e. \(g_i:X\rightarrow {\mathbb {R}}_{\ge 0}, i\in I\). Now given a RF \(f_i\) and its support \(B_i=\{x\in X|f_i>0\}\) considered as the subset of \({\mathbb {R}}^d\), one equates the support with \(U_i\), i.e.

$$\begin{aligned} B_i=U_i\subset {\mathbb {R}}^d, i\in I\,. \end{aligned}$$

Since the RF \(f_i\) is uniquely determined from its support \(B_i\), so \(f_i\) is usually identified with \(U_i\).

The main idea of universal logical model we are going to obtain is that we can show a homotopy equivalence between the set X of stimuli and the set \({\mathcal {N}}_X\) of active units in a topological space. This equivalence indicates that the space orientation reflected by mammals brains can be also found in functioning of Physarum polycephalum when reacting on the external stimuli and thus having control over its orientation in space. It is also the possibility, advocated in this paper, that this kind of universal mechanism may lay in the spatial orientations of any multi-agent biological system or any swarm.

It is a fairly well recognised phenomenon that the orientation in space is coded in the firing pattern of brain neuron. So, we take this model from the brain to describe any multi-agent biological system. It is known that there are place neurons in the hippocampus of brain which fire depending on the placement of an organism in particular places. After changing the places of organism, the brain changes the firing pattern of the place neurons. The fundamental questions arising in this context are how the orientation in space and the entire structure of the stimuli space X are coded in the code sets as above. The answer is based on reflecting the homotopy type of X by the code and the nerve theorem is perfectly suited to this purpose. In Sect. 2, we recall some basic facts relating to this and we also show how to implement the technique of the nerve of topological space to Physarum polycephalum or any swarm and to code the space orientation in its structure. In Sect. 3, we generalise the formalism to the infinite covers of X and thus show that we can appeal to intuitionistic logic there. In Sect. 4, we introduce a category for the swarm orientation. In Sect. 5, we close the paper with discussion of the results and present briefly the future directions of the approach.

The main result of the paper is to define a category for multi-agent biological systems like swarms—namely, it is a sheaf category (Sect. 4). It gives the most general approach to swarm computing. It is worth noting that there are proposed many algorithms in simulating some particular swarms: the Particle Swarm Optimisation [12], the Bacterial Foraging Optimisation Algorithm [13], the Artificial Bee Colony [14], the Cuckoo Optimisation Algorithm [15], the Social Spider Optimisation [16], the Ant Colony Optimisation [5], etc. Nevertheless, there is no general theory of swarm computing. In the paper, we are going to sketch one of the possible directions to this theory. Such a theory will show how multi-agent biological systems from unicellular to multi-cellular organisms realise a spatial logic in their space orientations.

2 Simplicial Objects and Spatial Orientation

One of the central arguments in this paper and for the brain place recognition, is presented by the nerve or active trace of finite cover \({\mathcal {U}}=\{U_1,U_2,...,U_n\}, n\in {\mathbb {N}}\) of \(X=\bigcup _{i=1}^{n}U_i\), where \(U_i,i=1,2,...n\) are open convex subsets of \({\mathbb {R}}^d\). Recall that a geometrical k-simplex, \(C^{(k)}\), is a complex hull of its \(k+1\) vertices – so it is a k-dimensional polytope. This k-simplex thus generalises: a point (0-simplex), a line element (1-simplex), a triangle (2-simplex), a tetrahedron (3-simplex) etc.

$$\begin{aligned} C^{(k)}=\{\lambda _0x_0+\lambda _1 x_1 +...+ \lambda _n x_n|\Sigma _{i=0}^{k}\lambda _i =1, \lambda _i\ge 0, x_i\in {\mathbb {R}}^k, i=0,1,...,k\}, \end{aligned}$$

where \(\{x_1-x_0, ... ,x_k-x_0\}\) is a linearly independent set of vectors in \({\mathbb {R}}^k\). The convex hull of any nonempty subset of the \(k+1\) points, say \(d+1,d<k\), is a face of the simplex provided that, it is a d-simplex as well. Any two faces \(F_1, F_2\) in \(C^{(k)}\), are disjoint or their intersection is a face in \(C^{(k)}\). A simplicial complex \({\mathcal {K}}\) is a set of simplices such that:

  1. 1.

    Each face of the complex in \({\mathcal {K}}\) is an element of \({\mathcal {K}}\).

  2. 2.

    Given two simplices \(C^{(k_1)},C^{(k_2)}\) in \({\mathcal {K}}\) if \(C^{(k_1)}\cap C^{(k_2)}=A\ne \emptyset \) then \(A=C^{(k_3)}\) is a common face of both simplices and belongs to \({\mathcal {K}}\) (from 1. above).

Somewhat similarly one defines an abstract simplicial complex as a family \(\Delta \subset P([n])\) of subsets of the finite set \([n]=\{0,1,2,...,n\}\) such that if \(\sigma \in \Delta \) and \(\tau \subset \sigma \) then \(\tau \in \Delta \). The point is that to a finite good cover \({\mathcal {U}}=\{U_1,U_2,...,U_n\}\) of X one assigns an abstract simplicial complex \({\mathcal {N}}({\mathcal {U}})\subset P([n])\) which is called the nerve or trace of \({\mathcal {U}}\):

If two open convex sets in \({\mathcal {U}}\) have nonempty intersection, then it belongs to the extension \(\overline{{\mathcal {U}}}\) of \({\mathcal {U}}\), i.e.

$$\begin{aligned} U_{\alpha }\cap U_{\beta }=U_{\alpha \beta }\ne \emptyset \text {, then } U_{\alpha \beta }\in \overline{{\mathcal {U}}} \text { and } \overline{{\mathcal {U}}} \supset {\mathcal {U}} . \end{aligned}$$

Representing each \(U_i\in {{\mathcal {U}}}\) by a point \(i\in [{n}]\) and all nonempty intersections \(U_i\cap U_j\) by \(\{i,j\}\in P([n])\) and all nonempty triple intersections \(U_i\cap U_j\cap U_k\) by \(\{i,j,k\}\in P([n])\) and so on, we have thus obtained the abstract simplicial complex, the nerve or trace of \({\mathcal {U}}\), i.e. \({\mathcal {N}}({\mathcal {U}})\).

In fact the nerve or trace \({\mathcal {N}}({\mathcal {U}})\) can be determined by its highest degree skeleton as shown by the following Helly’s theorem

Theorem 2.1

Given k convex open sets \(\{U_1,U_2,...,U_k\}\) in \({\mathbb {R}}^d\), \(d<k\) and if any subfamily of \(d+1\) sets \(U_i\) has nonempty intersection, then also \(\bigcap _{i=1}^{k}U_i\ne \emptyset \).

Crucial is the following nerve theorem

Theorem 2.2

\(X({\mathcal {U}})\) and \({\mathcal {N}}({\mathcal {U}})\) are homotopically equivalent.

In fact this equivalence holds between any paracompact space X with possibly infinite open cover \({\mathcal {U}}\), such that each finite intersection of elements of \({\mathcal {U}}\) is contractible, and its nerve \({\mathcal {N}}({\mathcal {U}})\) (see [21, p. 459]).

The nerve theorem gives the direct relationship between the space X of stimuli and the simplicial object which is the nerve of the convex open cover of X (see also [17]). This homotopy equivalence, or duality of topological space and simplicial space, is in the root of the brain functioning regarding the spatial orientation of living organism (e.g. [19, 20]). And this model can be treated as a model of space orientation of any multi-agent biological systems – from Physarum polycephalum and Amoeba proteus to social insects and mammal swarms. To understand this relationship in more detail let us consider the stimuli space \(X({\mathcal {U}})\), \({\mathcal {U}}=\{U_1,U_2,....,U_n\}\) where each \(U_i\) is realised by a RF as in the Introduction (the receptive field of the i-th stimulus \(f_i\) as exciting, or not, the i-th neuron or computational unit). Then the support of \(f_i\) can be identified with \(U_i\). In fact of neglecting the convexity requirement for \(U_i\) there holds quite general rule. To see it let us turn to the idea of code words from the Introduction. A sequence \(\sigma \in \{0,1\}^n\), where now we allow only signal activating the i-th neuron (unit) or its lack, represents a code. The totality of activating signals coming from all stimuli can be grouped in the receptive field code of \({\mathcal {U}}\) (RF code), i.e. \({\mathcal {C}}({\mathcal {U}})\subset \{0,1\}^n\) (see [19, 20]).

$$\begin{aligned} {\mathcal {C}}({\mathcal {U}})\overset{\text {def.}}{=}\left\{ \sigma \in \{0,1\}^n|\left( \bigcap _{i\in \text {supp}(\sigma )}U_i\setminus \bigcup _{j\notin \text {supp}(\sigma )}U_j \right) \ne \emptyset \right\} . \end{aligned}$$
(2.1)

Recall that a neural or trace code \({\mathcal {C}}\) of a system of n active units \(\{1,2,...,n\}=[n]\) is a subset \({\mathcal {C}}\subset \{0,1\}^n\) describing the pattern of activity and it comprises with code-words \(\sigma =\{s_1,s_2,...,s_n\}\in {\mathcal {C}}\). The support of \(\sigma \) is thus the set of computational units activated in \(\sigma \) and it is a subset of [n]. Thus, the support of neural code is

$$\begin{aligned} \text {supp}({\mathcal {C}})\subset 2^{[n]}. \end{aligned}$$

The following theorem shows the universality of the construction of neural codes, units for X, and receptive field codes when applied to systems of neurons in a brain or to systems of active members in a swarm.

Theorem 2.3

([20], Lemma 1). Let \({\mathcal {C}}\subset \{0,1\}^n\) be a neural code. Then for any \(d\ge 1\) there exists a stimulus space \(X\subset {\mathbb {R}}^d\) along with the collection of open sets \({\mathcal {U}}=\{U_1,U_2,...,U_n\}\), \(U_i\subset X\) such that \({\mathcal {C}}={\mathcal {C}}({\mathcal {U}})\). The sets \(U_i, i\in [n]\) are not necessarily convex.

By applying the entire construction (following e.g. [19]) to the hyppocampus part of the brain, formula (2.1) gives the correspondence between the subsets of positions in X and patterns of neural activity: (i) \((0)_i\) – no activation of i-th unit, (ii) \((1)_j\) – an activation of j-th unit. In this way codes carry information about the positions in X. The brains or any other multi-agent biological system can thus process the data which is at roots of awareness of the orienting and navigating within the space.

Let us turn to the more general case of Physarum polycephalum, Amoeba proteus or any swarm which certainly possess no neurons. Any multi-agent biological system from bacteria colonies to social insects and mammal swarms typically occupy certain spatial domain in \({\mathbb {R}}^3\) by a net of trace system (e.g. [25]). The excitation of individuals in these systems is performed by external stimuli (e.g. food doses) which results in the varying dynamics of the liquid excitation flows through the traces (i.e. through the tubes of Physarum polycephalum). It is known that after a certain time each swarm from unicellular to multi-cellular organisms builds an optimal logistic net of traces connecting nutrition doses, realising the most effective connections. This was in fact the source for the effective searching for the shortest connections, thus ‘solving’ the travelling salesman problem under some circumstances [22,23,24,25]. There is, however, another even more basic problem underlying such a behaviour. Namely, people are investigating the phenomena like that from the perspective of understanding cellular intelligence and the origins of cognition. Here we follow this direction and propose to assign to swarms, spreading over a 3-dimensional spatial region, a simplicial object – the nerve or trace of an open cover of the region, such that it explains the spatial orientation and a degree of self-control usually specific for the brain.

The link of the nerve or trace of the stimuli space X (suitably extended over a subset of \({\mathbb {R}}^d\)), i.e. \({\mathcal {N}}({\mathcal {U}})\) with the system, for example, of the tubes in Physarum polycephalum is given by the triangulation of X. Namely, still for the convex open cover \({\mathcal {U}}\) of X it follows from Helly’s theorem 2.1

Proposition 2.4

([19, 20]). \({\mathcal {N}}({\mathcal {U}})\) can be canonically identified with the triangulated space \(\Delta ({{\mathcal {C}}({\mathcal {U}})})\).

From the formal point of view, the system of swarm logistic traces which is developed by any multi-agent biological system when extending over a spatial region engulfing food portions scattered in the space can be seen as the triangulation of the space of stimuli. If the number of various kinds of stimuli is increasing the dimensionality d of \({\mathbb {R}}^d\) typically exceeds 3.

Example 1

Let us consider an example of expanding the plasmodium ofPhysarum polycephalum thorough growing its protoplasmic tubes. Let us take k convex open sets \({\mathcal {U}}= \{U_1,U_2,...,U_k\}\) in \({\mathbb {R}}^3\), where \(\bigcup _{i=1}^{k}U_i =X\), i.e. we have k external objects which can be detected by the plasmodium of Physarum polycephalum. Then \({\mathcal {N}}({\mathcal {U}})\subset P([k])\) is a set of possible traces in reaction to k objects. Each trace from \({\mathcal {N}}({\mathcal {U}})\) can be activated (excited) or deactivated. Then the code word \(\sigma \in {\mathcal {C}}({\mathcal {U}}) \subset \{0,1\}^k\) shows which points of an appropriate trace are activated (i.e. have the value of 1) – it means that these points participate in growing the logistic network of Physarum polycephalum.

Let us assume that \(k = 3\), see Fig. 1. After occupying \({\mathcal {U}} = \{U_1, U_2, U_3\}\) by protoplasmic tubes of Physarum polycephalum, we obtain \({\mathcal {N}}({\mathcal {U}})\) which is homotopically equivalent to \(X({\mathcal {U}})\).

Fig. 1
figure 1

Three convex open sets \(U_1, U_2, U_3\), presenting food pieces, are located around the plasmodium of Physarum polycephalum

After a period of time T, the protoplasmic tubes extend over and cover the three (or more) open domains representing the food pieces. Thus, they meet in the body of Physarum polycephalum in such a way that the resulting nerve stores information about the positions of the food via the dual local patches \(U_1, U_2, U_3\) which are extended to \({\overline{U}}_1, {\overline{U}}_2, {\overline{U}}_3\) and which can be further extended to a single open superset \({\overline{U}}\) containing all 3 as subsets. However, the emerging environment where the meeting takes place is to be changed into the intuitionistic logic and set theory. Using the terminology of the next section, \(U_1, U_2, U_3\) and \({\overline{U}}_1, {\overline{U}}_2, {\overline{U}}_3\) are stages in the sieves over \({\overline{U}}\) in the special sheaf category, where the intersections of open subsets are given by a pullback square in this category. Hence, in the next two sections we will analyse the categorical limit of dense resolutions of swarm networks allowing for infinitely many open sets in covers of regions in X. Such a procedure will allow for determining the categorical environment where arbitrary many food pieces and their interactions can be treated consistently.

3 Intuitionistic Logic as the Limiting Universal Logic for Multi-Agent Biological Systems

In this section we recognise the logic based on open covers of X thus on the structure of the nerve \({\mathcal {N}}({\mathcal {U}})\). The basic fact is the classic result by Tarski:

Lemma 3.1

If X is any topological space, the collection \({\mathcal {O}}(X)\) of its open subsets is a complete Heyting algebra \({\mathcal {H}}\). The underlying order of \({\mathcal {H}}\) is given by set-theoretic inclusion.

Remark 3.2

Heyting algebras generalise Boolean algebras and they represent intuitionistic logic (which is infinitely many-valued) in addition to 2- (or finitely many-) valued logics.

In order to interpret formulas of intuitionistic logic on \({\mathcal {O}}(X)\), we assign open sets to propositional atoms similarly as in the case of nerve (trace) of X where we have assigned open sets to points – nodes of the nerve. Let \(\alpha \) be an atomic formula of intuitionistic logic, then \(\llbracket \alpha \rrbracket \) is an open set in \({\mathcal {O}}(X)\). The next step in building the interpretation of complex formulas is given by the usage of operations from the Heyting algebra \({\mathcal {O}}(X)\) such that for any propositions \(\alpha ,\beta \), the following relations hold true:

$$\begin{aligned} \begin{aligned}&\llbracket \alpha \wedge \beta \rrbracket =\llbracket \alpha \rrbracket \cap \llbracket \beta \rrbracket \\&\llbracket \alpha \vee \beta \rrbracket =\llbracket \alpha \rrbracket \cup \llbracket \beta \rrbracket \\&\llbracket \alpha \rightarrow \beta \rrbracket =\mathrm {Int}\big ((X\setminus \llbracket \alpha \rrbracket )\cup \llbracket \beta \rrbracket \big )\\&\llbracket \lnot \alpha \rrbracket =\mathrm {Int}(X\setminus \llbracket \alpha \rrbracket )\\&\llbracket \top \rrbracket =X\\&\llbracket \bot \rrbracket =\emptyset \end{aligned} \end{aligned}$$
(3.1)

where \(\mathrm {Int}(A)\) is an interior of set \(A\subset X\). Hence, the syntax of intuitionistic propositional logic is reflected in the algebra of open sets in \({\mathcal {O}}(X)\).

Remark 3.3

Note that Lemma 3.1 holds for finite topological spaces X as well as for infinite ones.

Tarski, 1938 1. If \(\phi \) is intuitionistically provable in intuitionistic propositional logic, then, for any topological interpretation \((X,\llbracket \, \rrbracket )\) in any topological space X, \(\llbracket \phi \rrbracket =X\).

2. If \(\phi \) is non-provable intuitionistically, then there exist X and an interpretation \((X,\llbracket \, \rrbracket )\) such that \(\llbracket \phi \rrbracket \ne X\)

Remark 3.4

Note that the following equivalence holds true: \(\phi \) is intuitionistically provable in intuitionistic propositional logic iff \(\phi (a_1,a_2,\ldots ,a_n)=\top \) holds true for any Heyting algebra \({\mathcal {H}}\) and \(a_{1},a_{2},\ldots ,a_{n}\in {\mathcal {H}}\). Since not all complete Heyting algebras are representable as topologies on X, so this equivalence generalises the property 1. above.

Let \({\mathcal {L}}\) be a standard propositional language of intuitionistic logic. Its formulas \(\phi _1, \dots , \phi _n,\dots \) describe real-time experiments with unicellular or multi-cellular organisms (from Physarum polycephalum and Amoeba proteus to swarms of social insects and mammals). These experiments are performed by locating some objects, which can become stimuli (attractants and repellents), at different places around the organisms. Then each singular stimulus \(\llbracket \phi \rrbracket \) represents a convex open set and it is described by an appropriate atomic proposition \(\phi \). Any logical composition \(f(\phi _1, \dots , \phi _n)\) of atomic formulas \(\phi _1, \dots , \phi _n\) is to describe the experiment with n objects \(\llbracket \phi _1 \rrbracket ,\dots , \llbracket \phi _n \rrbracket \) by means of logical composition \(f(\llbracket \phi _1 \rrbracket ,\dots , \llbracket \phi _n \rrbracket )\) in the Heyting algebra.

Assume that there are two external objects: \(\llbracket \alpha \rrbracket \) and \(\llbracket \beta \rrbracket \), which become the stimuli. Then \(\llbracket \alpha \rrbracket \cap \llbracket \beta \rrbracket \) means that the swarm occupies both \(\llbracket \alpha \rrbracket \) and \(\llbracket \beta \rrbracket \); \(\llbracket \alpha \rrbracket \cup \llbracket \beta \rrbracket \) means that the swarm occupies \(\llbracket \alpha \rrbracket \) or \(\llbracket \beta \rrbracket \); \(\mathrm {Int}(X\setminus \llbracket \alpha \rrbracket )\) means that the swarm avoids the place of \(\llbracket \alpha \rrbracket \).

Example 2

Let us consider an example of building the logistic network by foraging ants. Suppose that we decide to locate three potential stimuli: two attractants \(U_1, U_2\) and one repellent \(U_3\), see Fig. 2. Then the universe \(X=\bigcup _{i=1}^{3}U_i\). Let \(\llbracket \alpha \rrbracket = U_3\). Then for this experiment the proposition \(\lnot \alpha \) has the meaning \(\mathrm {Int}(X\setminus \llbracket \alpha \rrbracket )\).

Fig. 2
figure 2

Three convex open sets \(U_1, U_2, U_3\), where \(U_1, U_2\) present food pieces and \(U_3\) presents a repellent which must be avoided by ants

The connection between topology and intuitionistic logic works for all topologies on spaces which comprise also covers by open sets discussed in the context of the stimuli space X. The covers were finite so far thus we need to focus on a way how to extend the finite to infinite covers and check whether the limiting case would fit with the intuitionistic logic/topology connection.

From (2.1) it follows that as long as the intersections \(U_i\cap U_j\) are nonempty, they contribute non-trivially to the neural code \({\mathcal {C}}({\mathcal {U}})\). Let us consider an infinite (countable) cover \({\mathcal {U}}^{*}\) of X. Extending \({\mathcal {U}}\) to \({\mathcal {U}}^{*}\) is given by still finite intersections of finite subfamilies of \({\mathcal {U}}^{*}=\{U_1,U_2,\ldots U_k \ldots \}\). This horizontal case leads to the \(\text {RF}^{*_h}\) code which eventually suppose infinite collections of finite strings of excitation as members of \({\mathcal {C}}({\mathcal {U}}^{*})\). However, such an excitation spreading over X in a series of steps, would require an infinite number of extension which could presumably require an infinite time to be realised, and this is a true limitation from the point of view of real processes in the brain or swarm. Even neglecting this difficulty one infers that

$$\begin{aligned} {\mathcal {C}}({\mathcal {U}})\subset {\mathcal {C}}^h({\mathcal {U}}^{*})\subset 2^{\omega }, \text { where }{\mathcal {C}}({\mathcal {U}})\subset 2^{[n]}. \end{aligned}$$

Here \(\sigma \in {\mathcal {C}}^h({\mathcal {U}}^{*})\) is finite, though the entire set – the RF code \({\mathcal {C}}^h({\mathcal {U}}^{*})\) – would be infinite.

The vertical case of describing the excitation extending over infinite open covers of X relies on assuming infinite intersections of infinite subfamilies \(\{U_{\kappa }\}_{\kappa \in K\subset I}\subset {\mathcal {U}}^{*}\), \(\bigcap _{\kappa \in K}U_{\kappa }\ne \emptyset \). Similarly, it holds:

$$\begin{aligned} {\mathcal {C}}({\mathcal {U}})\subset {\mathcal {C}}^v({\mathcal {U}}^{*})\subset 2^{\omega }, \end{aligned}$$

however, now the RF code \({\mathcal {C}}^v({\mathcal {U}}^{*})\) supposes infinite strings coming from an infinite vertical depth of intersecting open sets in \({\mathcal {U}}^{*}\). The entire set \({\mathcal {C}}^v({\mathcal {U}}^{*})\) can be finite, but also infinite.

Yet another, the most general case, for infinite extensions is one obtained in topologies \({\mathcal {O}}(X)\). The point is that any open cover \({\mathcal {U}}(X)\) fulfils

$$\begin{aligned} {\mathcal {U}}(X)\subset {\mathcal {O}}(X), \end{aligned}$$

moreover, any subcover \({\mathcal {U}}(X)_{|\text {RF}} \subset {\mathcal {U}}(X)\), so that \({\mathcal {U}}(X)_{|\text {RF}} \subset {\mathcal {U}}(X)\subset {\mathcal {O}}(X)\). Here \({\mathcal {U}}(X)_{|\text {RF}}\) is a collection of open sets \(U_i\in {\mathcal {O}}(X)\) excited precisely in the RF code \({\mathcal {C}}({\mathcal {U}}_{|\text {RF}})={\mathcal {C}}({\mathcal {U}})\). Finally, we arrive at

$$\begin{aligned} {\mathcal {U}}(X)_{|\text {RF}} \subset {\mathcal {U}}(X)\subset {\mathcal {U}}^{*}(X) \subset {\mathcal {O}}(X) . \end{aligned}$$
(3.2)

Besides for any open subdomain \(Y\subset X\) such that \(Y=\bigcup _{i\in I}\{U_i|U_i\in {\mathcal {U}}(X)_{|\text {RF}}\}\), \({\mathcal {O}}(Y)\) generalises \({\mathcal {U}}(X)_{|\text {RF}}\)

$$\begin{aligned} {\mathcal {U}}(X)_{|\text {RF}}\subset {\mathcal {O}}(Y)\subset {\mathcal {O}}(X). \end{aligned}$$
(3.3)

The patterns of excitation are coded in open covers of X. The activity, motility and growing of swarm networks (such as tube nets of Physarum polycephalum) is often realised in the presence of variety of stimuli like many food portions scattered in the 3-dimensional space (see also [18]). The activation then meets and reacts somehow in the members of swarms. The containment relations above show that the universal environment for considering all the effects by stimuli is the (\(\sigma \)-algebra of the) topology \({\mathcal {O}}(X)\) of the resulting stimuli space X. Let \(\text {RF}1\) be the RF code of the excitation 1 in the vicinity of stimulus \(a_1\in X\). Similarly, we assign RFk to \(a_k\in X\). Hence, it holds:

Lemma 3.5

Let X be the stimuli space for \(a_1,\ldots ,a_k,\ldots , a_n\) and \(X\subset {\mathbb {R}}^d\). The universal algebraic environment for multi-agent biological systems reacting to the stimuli is represented by \({\mathcal {O}}(X)\).

Proof

This is a direct conclusion from the relations of (3.2), (3.3):

$$\begin{aligned} {\mathcal {U}}(X)_{|\text {RFk}}\subset {\mathcal {O}}(Y_k)\subset {\mathcal {O}}(X), k=1,2,\ldots , n \end{aligned}$$

and from the fact that any open \(Y_k\subset X\) is extended to an open cover of X. \(\square \)

Let X be a minimal stimuli space, where stimuli \(a_1,\ldots ,\ldots , a_n\) belongs to it. We thus can formulate the following general property of logic of infinitely extended open covers.

Theorem 3.6

The universal logic for multi-agent biological systems reacting to stimuli belonging to the space X is the intuitionistic logic of the topology \({\mathcal {O}}(X)\).

Proof

The Lemma 3.1 shows that there is the duality between algebraic structure of \({\mathcal {O}}(X)\) (Heyting algebras) and the intuitionistic logic of it. Then Lemma 3.5 directly proves the result. \(\square \)

In the next section we will see that this connection is even more stringent.

4 The Categorical Generalisation

The partial order determined by the inclusion relation on \({\mathcal {O}}(X)\) suggests yet another interpretation of the logical structure of swarms from Physarum polycephalum and bacteria colonies to social insects and other animals. Namely, equation (2.1) indicates that for infinite covers with an infinite depth of intersections, there emerge maximal chains of infinite length, linearly ordered by inclusion. In fact such chains contribute non-trivially to \({\mathcal {C}}({\mathcal {U}})\) as in (2.1). Having in mind the results of the previous section, we could ask the question about the logic of such chains. The proper indication is given by the constructions known from category theory.

To define a category \({\mathcal {K}}\) one needs to specify the sets, or proper classes, of objects \(O_1\) and the morphisms (arrows) \(O_2\) between the objects such that the following properties hold true:

  1. 1.

    The triple product of morphisms \(\alpha _1\alpha _2\alpha _3\) is defined, whenever there are defined \( (\alpha _1\alpha _2)\alpha _3, \alpha _1(\alpha _2\alpha _3)\) and then the associative law takes place:

    $$\begin{aligned} \alpha _1\alpha _2\alpha _3= (\alpha _1\alpha _2)\alpha _3 = \alpha _1(\alpha _2\alpha _3), \; \alpha _1,\alpha _2,\alpha _3\in O_2. \end{aligned}$$
  2. 2.

    \(\alpha _1\alpha _2\alpha _3\) is defined, whenever \(\alpha _1\alpha _2\) and \(\alpha _2\alpha _3\) are defined.

  3. 3.

    For each \(\alpha \in O_2\) there exist identities \(e_1,e_2\in O_2\) such that \(e_1\alpha =\alpha e_2=\alpha \).

  4. 4.

    For each object \(X\in O_1\), there exist an identity \(e_X\in O_2\).

  5. 5.

    For each identity e, as in 3. above, there exists \(X\in O_1\) such that \(e=e_X\).

If both \(O_1\) and \(O_2\) are actually sets, the category is small, otherwise large. One can easily verify that \(({\mathcal {O}}(X),\subset )\) is a small category where \(O_1={\mathcal {O}}(X)\) and \(f: A\supset B\) is a morphism \(f\in O_2\).

Remark 4.1

Given a category \({\mathcal {K}}\), one defines the opposite category, \({\mathcal {K}}^{op}\), with the same set of objects \(O_1\) as \({\mathcal {K}}\) and all arrows with reversed orientations, i.e. given \(\alpha \in O_2\) and \(e_1,e_2\) as in 3. above, then from 4. it follows that there are objects \(a_1,a_2\in O_1\) such that the arrows \(\alpha \) can be seen as starting from \(a_1\) and aiming at \(a_2\). Hence, the reverse arrow starts with \(a_2\) and aims at \(a_1\) and they precisely form the arrows in \({\mathcal {K}}^{op}\).

Remark 4.2

The category of all sets (which is not a set itself) and functions between them is SET. This is in a sense model category which is, however based on the 2-valued (classical) Boolean algebra and, consequently, the logic it determines (its internal logic) is the classical 2-valued logic (e.g. [26]). In general, the internal logic is often different from classical and in the case of toposes (the special class of categories resembling SET), the internal logic is based on Heyting algebras (e.g. [26]).

Given a small category \({\mathcal {K}}\), it is a usual practice to study the functors \(F:{\mathcal {K}}^{op}\rightarrow SET\) which could shed light on the difference of \({\mathcal {K}}\) and SET. In particular, the category of all such functors is called presheaf category, depicted as \(SET^{{\mathcal {K}}^{op}}\). The so-called ‘sheafification’ which is a modification of a presheaf category, resulting in the sheaf category, and depicted \(Sh({\mathcal {K}})\), is another usefull form of a functor category.

Remark 4.3

All the categories SET, \(SET^{{\mathcal {O}}(X)^{op}}\), \(Sh({\mathcal {O}}(X))\) are the examples of toposes [26]. Topos theory is a vast and rich branch of mathematics especially in foundations of mathematics which bridges many fields like algebra, logic, geometry, set theory or topology including algebraic topology (e.g. [27]). Toposes found also their applicability in quantum mechanics and physics in general.

The construction of the presheaves in \(SET^{{\mathcal {O}}(X)^{op}}\) can be based on the notion of sieves. Our concern here is that sieves are related to maximal chains in \({\mathcal {O}}(X)\).

Sieves appear when one wants to categorify the notion of covering of an open set on a topological space. In categories this becomes the covering of an object by a family of arrows. A sieve S on an object \(c\in O_1\) is a collection of arrows \(S\subset O_2\) such that for arrows \(g\in O_2\)

$$\begin{aligned} \text {if } f\in S \text {, then } f\circ g \in S, \end{aligned}$$

whenever the composition above makes sense.

Translating this definition into open sets in X, a sieve on \(U\in {\mathcal {O}}(X)\) would be a family of finer open subsets of U along with finer subsets of them and so on. In this way we, have a collection of maximal chains of open intersecting subsets. This covering family \(J_{{\mathcal {O}}(X)}\) is by itself the categorification of the cover of U which gives rise to a categorical version of topology – the Grothendieck topology which always contains the maximal sieve for any U.

Remark 4.4

A Grothendieck topology on a category \({\mathcal {K}}\) is the assignment \(J:a\rightarrow J(a)\), where \(a\in O_1\) is an arbitrary object of \({\mathcal {K}}\) and J(a) is a collection of sieves on a, where following conditions hold trues:

  1. 1.

    The maximal sieve on a is a member of J(c).

  2. 2.

    Let \(S_1, S_2\) be sieves on a and \(S_1\in J(a)\) and \(S_1\supset S_2\), then \(S_2\in J(a)\).

  3. 3.

    There exists the sieve \(R\in J(a)\), which is a composite of sieve \(S\in J(a)\) and family of certain sieves, and this R behaves functorially with respect to the changes of arrows in S and with respect to the changes of the object \(a\rightarrow d\) (see [26]).

As we noted before, such maximal chains give nontrivial contributions to \({\mathcal {C}}({\mathcal {U}}^{*})\). From the categorical point of view, sieves are essential building blocks for construing sheaves on \({\mathcal {K}}\). Thus, for \({\mathcal {K}}={\mathcal {O}}(X)\) Grothendieck topologies and covering families \(J_{{\mathcal {O}}(X)}\) of sieves determine categorical sheaves on \({\mathcal {O}}(X)\). However, the following statement takes place:

Lemma 4.5

For any topological space X the category \(Sh({\mathcal {O}}(X),J_{{\mathcal {O}}(X)})\) is equivalent to the ordinary category Sh(X) of sheaves on X.

The above lemma holds since the Grothendieck topology \(J_{{\mathcal {O}}(X)}\) on \({\mathcal {O}}(X)\) contains sieves S on \(U\in {\mathcal {O}}(X)\) where \(S=\{U_i\hookrightarrow U|i\in I\}\) such that

$$\begin{aligned} S\in J_{{\mathcal {O}}(X)}(U)\iff \bigcup _{i\in I}U_i=U. \end{aligned}$$

In this way, the maximal sieves give nontrivial contributions to \({\mathcal {C}}({\mathcal {U}}^{*})\) and also build sheaves on X. That is why we consider Sh(X) as suitable formal generalisation of \({\mathcal {O}}(X)\) in the context of swarm motility and reaction on stimuli.

Lemma 4.6

There exist canonical embeddings

$$\begin{aligned} {\mathcal {O}}(X)\rightarrow SET^{{\mathcal {K}}^{op}}\rightarrow Sh(X). \end{aligned}$$

Proof

The embedding \({\mathcal {O}}(X)\rightarrow SET^{{\mathcal {K}}^{op}}\) is the Yoneda embedding of a (small) category to the corresponding category of presheaves. The second embedding \(SET^{{\mathcal {K}}^{op}}\rightarrow Sh(X)\) is derived from the sheafification functor \(SET^{{\mathcal {K}}^{op}}\rightarrow Sh({\mathcal {O}}(X),J)\). Then the statement in the lemma follows from Lemma 4.5. \(\square \)

Theorem 4.7

The limiting logic and set theory of multi-agent biological systems reacting on stimuli and assuming interactions between them, is given by the internal logic and set theory of Sh(X), which are intuitionistic.

This result follows from Lemma 4.6 showing that Sh(X) is the limiting category extending \({\mathcal {O}}(X)\) and from the fact that Sh(X) is a topos whose internal logic is based on the Heyting algebra \({\mathcal {O}}(X)\). Lemma 4.5 shows that Sh(X) is equivalent to the category of sheaves on the above Heyting algebra, while SET is equivalent to \(Sh(\{0,1\})\) – the category of sheaves on the 2-valued Boolean algebra. From that point of view it is evident that Sh(X) is essentially non-classical with intuitionistic internal logic [26]. Being a topos Sh(X) has the internal set theory which is intuitionistic [26].

5 Discussion

We have analysed the situation of limiting logic for swarms reacting on stimuli, with the stimuli space \(X\subset {\mathbb {R}}^d\), and assuming the interaction of excitation. The limiting case has been determined by taking infinite covers of the topological space X. Firstly, we have shown that the topology \({\mathcal {O}}(X)\) is the object encompassing a various excitation carried out by systems of open sets in X and such that we suppose an interaction of excitation. Moreover, the nerves (traces) of the covers \({\mathcal {U}}_i\) of X correspond to the excitation in the swarm logistic networks. Next, we have developed the infinite cover case toward categorical constructions and observed that \(Sh({\mathcal {O}}(X))\) would be a natural limiting case of infinite covers. This abstract construction as a category is, however, equivalent to the ordinary category of sheaves on a topological space. This shows that the generalisations of X with finite covers to infinite covers of infinite intersections depths, even though goes through presheaf topos \(SET^{{\mathcal {O}}(X)^{op}}\), and the sheaves on Heyting algebra \({\mathcal {O}}(X)\), finally leads to the topological space of sheaves on X. Hence, \(X\rightarrow {\mathcal {O}}(X)\rightarrow Sh(X)\) is a final description of the generalisations. Finally, the intuitionistic logic and set theory of the topos Sh(X) is assigned to this limiting case. We have observed (following [19, 20]) that the duality of the nerve (logistic trace) of cover of X and open neighbourhoods in space explains the orientation in space of swarms, but it is also characterising the brains of mammals activity (hyppocampus region) with respect to the space orientation. That is why it would be quite interesting to push farther this duality over categorical notion of the nerve of category (\(SET^{{\mathcal {O}}(X)^{op}}\)) into the internal topological space and its cover. Possibly intuitionistic logic and internal spaces in toposes would be the right abstract base for recognising patterns of functioning of swarms and would find its place in the study of brain activity.

Let us discuss certain choices made in the paper. As a rule, we work with open covers and open subsets of X. One could instead take closed convex subsets and cover which generally lead to the similar results. The reason for such rough equivalence is the version of the nerve theorem based on finite closed covers of X (see [29, p. 1850]). However, there are some differences when infinite cover limit is taken as in Secs. 3 and 4. First, for infinite covers and infinite depth of closed subsets they can intersect in a single point. We consider this situation unrealistic from the point of view of determining the localisation region in physical space of stimuli. It is rather certain unsharp region in \({\mathbb {R}}^3\), hence open U, resulting as recognized by an organism localization of a stimulus. Second, the limiting categorical logic of presheaves on partial order of closed covers of X, is given by a co-topos rather then by the topos of sheaves. While this difference is rather subtle from the point of view of real biological systems, still it leads mathematically to the paraconsistent logic and we do not decide here that such limiting logic cannot be a valid tool for grasping the behaviour of real systems. This interesting problem is, however, deferred to be analysed separately. Therefore we postpone the full fledged demonstration of this mechanism based on examples to a separate publication.

One could wonder how concrete biological systems based on these universal mathematical constructions have the chance to aim at unique solution in the real world. As we believe, and which was not demonstrated decisively here, the key indication comes from mathematics and partly from physics. These are optimization processes of the topological constructions, leading to determining the link between combinatorial, discrete and continuous, or even smooth, structures of topological spaces [30]. As the result there is not only the nerve of a topological space which is to be determined and which depends on covers of X, but also the nerve is the most effective in the algorithmic and computational sense and as such, it is unique or almost unique [30]. One additional aspect of the effectiveness of this mechanism relies on the fact known from physics that a physical space (or 4-dimensional spacetime) is very precisely, if not perfectly, represented by the 3-dimensional smooth manifold (4-dimensional Minkowski manifold, respectively) so that the recognition of positions in 3-space is also very finely grasped by the dual nerve construction. The more thorough presentation of this mechanism, based on examples, will be presented separately.

In the course of time we are going to construct a simulation model within the object-oriented programming in the way of [32] to check the exressibility of our topological construction presented in this paper. Our main motivation was to propose the broadest possible mathematical framework in terms of category theory for studying logistic behaviour in space navigation of living beings.

Recently [28] we have found that intuitionism may indeed be a proper feature of intelligent swarms considered as realising certain computational tasks. Even the deeper variation on the internal vs. external perspectives led recently researchers to formulating and analysing the proposal stating that for the appearance of ‘mind’ as logical manifestation of the structure, i.e. categorical ‘brain’, is responsible for the duality (the pair of adjoint functors) between categories LANG of categories and MIND of theories [31]. Such a universal and categorical mechanism of creation meanings by the brain could, in principle, serve as roots of consciousness emerging in the structure of brain. This, however, requires further studies.