1 Introduction

The fungi is among the largest, most widely distributed group of living organisms [15]. Fungi can grow as individual cells or in a interconnected network of hyphae. These hyphae that grow at their tips and branch sub-apically can be compartmentalized by porous septa that can be either in a closed or open state. In the open state, cytoplasm can stream from one compartment to the other or even from hypha to hypha. In the closed state, the compartments can act as individual entities although there is still interaction with neighboring cells [34]. Mycelia can be thousands of years old and can cover large surface areas. The largest known mycelium, belonging to the Armillaria genus covers an area of 965 hectares [30]. The fungi show a high degree of adaptability to environmental conditions. They are demonstrated to efficiently explore confined spaces with their hyphae [17, 19,20,21,22]. In fact, they even form different types of hyphae within the mycelium [31]. Optimisation of the mycelial network [14] is quite similar to that of slime mould P. polycephalum, e.g. in terms of proximity graphs [1] and transport networks [2]. Taking into account the ubiquity, range of length scales and spatio-temporal dynamics exhibited by the fungi, they represent a promising research target within the context of unconventional computing.

The motivation of this paper is to contribute to uncovering basic mechanisms of decision making in the fungal network in terms of Boolean gates and circuits. Mechanisms of computation discovered in mycelium networks could be utilised in future designs of electrical analog computing circuits [32] and to design and program computing schemes embedded into living fungal architectures [6].

A first step toward discovering the computing potential of fungal networks would be to estimate frequencies of logical gates and simple circuits realisable in a single fungal colony. We implement this idea using three techniques: numerical modelling of spiking events on fungal colony, modelling the colony as a resistive and capacitive (RC) network and mining logical circuits.

In the first technique, logical gates are calculated based on the temporal co-occurrence of spikes emerging as responses to different input strings [10]. Why do we consider spikes of electrical potential? Because these spikes are manifestations of the calcium waves that travels along mycelium networks and implement information between distant parts of the mycelium network and, possibly, participate in the information processing. First discovery of the electrical potential spikes has been done via intra-cellular recording of mycelium of Neurospora crassa [29]. Further confirmed in intra-cellular recordings of action potential in hypha of Pleurotus ostreatus and Armillaria bulbosa [25], and observed in the extra-cellular recordings of fruit bodies resulting from substrates colonized by the mycelium of Pleurotus ostreatus [5] (Fig. 1).

Spikes of fungal electrical potential are notoriously slow, with a minimum spike duration of 2 mins and maximum up to an hour. Thus the techniques of spikes based logical circuits might not be suitable for practical applications. Two other techniques exploit principles of electrical analog computing [11, 27]. True and False values are represented by above threshold and below threshold voltages. Due to the non-linearity of the conductive substrate along electrical current pathways between input and output electrodes, the input voltages are transformed and thus logical mappings are implemented.

Detailed descriptions of these techniques can be found in [10, 11, 27]. Here we provide an updated overview of the approaches and provide an integrative analysis of the results.

Fig. 1
figure 1

Exemplar spikes of extracellular electrical potential propagating in fungal mycelium

2 Methods

2.1 Colony Imaging

We have grown Aspergillus niger fungus strain AR9#2 [33]. This strain expresses Green Fluorescent Protein (GFP) from the glucoamylase (glaA) promoter. A fluorescence of GFP was localised in micro-colonies using a DMI 6000 CS AFC confocal microscope (Leica, Mannheim, Germany). Micro-colonies were imaged at 20\(\times \) magnification (HC PL FLUOTAR L 20 \(\times \) 0.40 DRY). Z-stacks of imaged micro-colonies were made using 100 slices with a slice thickness of 8.35 m. 3D projections were made with Fiji [28].

2.2 Numerical Modelling

Fig. 2
figure 2

Example of the fungal colony, \(1000 \times 960\) pixels used as a template conductive for FHN. A configuration of electrodes is superimposed on the image

In our research we choose some image of the colony, from the middle of the z-stack, as a conductive template. Then the image of the fungal colony (Fig. 2) was projected onto a \(1000 \times 960\) nodes grid C.

We simulated electrical activity of the colony with FitzHugh-Nagumo (FHN) equations [16, 24, 26]:

$$\begin{aligned} \frac{\partial v}{\partial t}= & {} c_1 u (u-a) (1-u) - c_2 u v + I + D_u \nabla ^2 \end{aligned}$$
(2.1)
$$\begin{aligned} \frac{\partial v}{\partial t}= & {} b (u - v), \end{aligned}$$
(2.2)

where u is a value of a trans-membrane potential, v a variable accountable for a total slow ionic current, or a recovery variable responsible for a slow negative feedback, I is a value of an external stimulation current. The current through intra-cellular spaces is approximated by \(D_u \nabla ^2\), where \(D_u\) is a conductance. We composed the system applying the Euler method with the five-node Laplace operator, assuming a time step \(\Delta t=0.015\) and a grid point spacing \(\Delta x = 2\), while other parameters were as follows \(D_u=1\), \(a=0.13\), \(b=0.013\), \(c_1=0.26\), \(c_2=0.095\). To explicate dynamics of excitation in the fungi network, we simulated electrodes by defining a potential \(p^t_x\) at an electrode location x as \(p_x = \sum _{y: |x-y|<2} (u_x - v_x)\).

2.3 Resistive and Capacitive Network Modelling

Fig. 3
figure 3

A graph representation of a single fungal colony. Each frame shows the graph after a 36\(^{\circ }\) rotation around the z-axis

We obtained a 3D graph (Fig. 3) from the z-stacks of the colony. It was converted to a resistive and capacitive (RC) network, by assigning to each edge a function of a resistor or a capacitor at random. The magnitudes of the resistance and capacitance were functions of the length of the edges/connections. We have chosen resistances in the order of kOhms and values of capacitance in the order of pF. We selected ground nodes and sources (positive voltage nodes) at random. The trials were run on 1000 networks (with the same architecture but different values of resistance and capacitance). During SPICE modelling we used two voltage pulses of 60 mV on randomly chosen positive nodes.

We modelled the fungal colony in serial RC networks (resistors and capacitors are connected in series) and parallel RC networks (resistors and capacitors are connected in parallel), see basics in [23]. The output voltages have been binarised with the threshold \(\theta \): \(V>\theta \) symbolises logical True otherwise False.

2.4 Experimental Laboratory Mining of Circuits

A hemp shavings substrate was colonised by the mycelium of the grey oyster fungi, P. ostreatus (Ann Miller’s Speciality Mushrooms Ltd, UK). Hardware was developed that was capable of sending sequences of 4 bit strings to a mycelium substrate. The strings were encoded as step voltage inputs where -5 V denoted a logical 0 and 5 V a logical 1. The hardware was based around an Arduino Mega 2560 (Elegoo, China) and a series of programmable signal generators, AD9833 (Analog, USA). The 4 input electrodes were 1 mm diameter platinum rods inserted to a depth of 50 mm in the substrate in a straight line with a separation of 20 mm. Data acquisition (DAQ) probes were placed in a parallel line 50 mm away separated by 10 mm. The electron sink and source was placed 50 mm on from DAQ probes. There were 7 DAQ differential inputs from the mycelium substrate to a Pico 24 (Pico Technology, UK) analogue-to-digital converter (ADC), the 8th channel was used to pass a pulse to the ADC on every input state change. There were a total of 14 repeats. A sequence of 4 bit strings counting up from binary 0000 to 1111, with a state change every hour, were passed into the substrate. Boolean strings were extracted from the data, where a logic ‘1’ was noted for a channel if it had a peak outside the threshold band for a particular state, else a value of ‘0’ was recorded. The polarity of the peak was not considered. The sum of products (SOP) Boolean functions were calculated for each output channel. For each repeat there were 7 channels and 32 thresholds giving total of 3136 individual truth tables.

3 Results

3.1 Spikes Derived Logical Gates

We adopt the encoding procedure developed by us in [9]. We select two electrodes as inputs x and y. We treat logical True, or ‘1’ as an impulse injected in the fungi network via input electrode. For example, if \(x=1\), then the location for x is excited, if \(x=0\), the location is not excited.

Each spike is understood as logical True. The spikes occurring within less than \(2 \cdot 10^2\) iterations are seen as occurring simultaneously. We assume that spikes are separated if their occurrences have more than \(10^3\) iterations apart. Figure 4 is to illustrate it.

Fig. 4
figure 4

Examples of electrical potential spikes recorded on the electrode 7. The data represent responses to input impulse strings, entered via electrodes 5 and 15, inputs (01), black dashed line, (10), red dotted line, (11), solid green line. The locations of electrodes are shown in Fig. 2

Fig. 5
figure 5

Recording of electrical potential from all electrodes in responses to inputs in response to inputs (01), black line, (10), red line, (11), green line, injected as spikes via electrodes \(E_x=5\) and \(E_y=15\)

Table 1 Frequencies of Boolean gates found for chosen pairs of input electrodes 3 and 13
Fig. 6
figure 6

Comparative relationships of logical gates found in the mycelium network analyzed in this article, black disc and solid line; slimy mold Physarum polycephalum [18], black circle and dotted line; succulent plant [8], red snowflake and dashed line; one molecule of protein verotoxin [3], light blue ‘+’ and dash-dot line; actin bundles network [9], green triangle pointing right and dash-dot-dot line; actin monomer [4], magenta triangle pointing left and dashed line. Area of xor gate is magnified in the insert. Lines are shown for viewing direction only

Frequencies of Boolean gates found on the electrodes for chosen pair of input electrodes are collected in Table 1. The most frequent gates are select x and select y gates and occur similar frequencies. The and-not gates \({\overline{x}}y\) and \(x{\overline{y}}\) less common than select gates. We detect that the gates xy and \(x+y\) occur with almost the same frequency with the gate \(x+y\). The most rare gate is a logical exclusion \(x\oplus y\).

The overall distribution of the ratio of gates discovered is shown in Fig. 6. The distribution demonstrates frequencies of discoveries of the four-input-one-output logical gates and could be used for characterisation of a computational power of the fungal substrates. This is accompanied by distributions of gates detcted in experimental laboratory reservoir computing with slime mould Physarum polycephalum [18], succulent plant [8] and numerical modelling experiments on computing with protein verotoxin [3], actin bundles network [9], and actin monomer [4]. The distributions of gates discovered in natural systems are alike to each other in the hierarchies of the gates frequencies. Namely, gates selecting one of the inputs are most common, they are followed by or gate, then by not-and an and-not gates. The gate and is typically less frequent. The gate xor is a totally rare.

3.2 Resistive and Capacitive (RC) Networks

Fig. 7
figure 7

Detection of the following gates: and, black, or, green, and-not, red, and select, blue, for \(\theta \in [0.0001, 0.05]\), with \(\theta \) increment 0.0001, in a fungal colony simulated by serial RC networks, b fungal colony simulated by parallel RC networks

There are sixteen types of two-input-one-output Boolean gates. The ‘active’ gates, i.e. those where zero inputs evoke a non-zero response could not be realised in the passive electrical model of a fungal network. They realisable gates are and, or, and-not (x and not y and not x and y), select (select x and select y) and xor. The exclusion gates xor have not been detected in any of the RC models of the fungal colony.

The serial RC networks demonstrate that gates and, select and and-not have some frequencies; but we do not see or gates. The number n of the gates can decrease thanks to a power law with increase of \(\theta \): \(n_{{\text{ and-not }}}=72 \cdot x^{-0.98}\), \(n_{{\text{ select }}}=2203 \cdot x^{-0.48}\), \(n_{{\text{ and }}}=0.02 \cdot x^{-1.6}\). Number of and gate oscillates is shown in Fig. 7a, perhaps due to its insignificant presence in the samples. The oscillations are close to zero base when \(\theta \) exceeds 0.001.

The model of parallel RC networks gives only gates and, select and or. The number of or gates decreases quadratically and becomes nil when \(\theta >0.03\). The frequency of and gates grows near linearly, \(n_{{\text{ and }}}= -1.72 \cdot 10^6 + 2.25 \cdot 10^8 \cdot x\), with increase of \(\theta \). The number of select gates reaches its maximum at \(\theta =0.023\), and then begins to lessen with the further grow of \(\theta \): \(n_{{\text{ select }}}= 9.61 \cdot 10^6 + 1.21 \cdot 10^9 \cdot x - 2.7 \cdot x^2\).

3.3 Experimental Laboratory Mining

Fig. 8
figure 8

Counts of realised Boolean functions discovered in laboratory experiments. Horizontal axis is a decimal representation of functions. Vertical axis is a number of functions discovered in experiments

We have discovered total of 3136 4-inputs-1-output Boolean functions. 470 unique functions are detailed in [27]. Figure 8 shows the Boolean function distribution. The two peak values were logical False, \(n=238\), and logical True, \(n=237\). The highest occurring non-trivial gate was \({\overline{A}}+{\overline{B}}+{\overline{C}}+{\overline{D}}\), \(n=145\). The top nine occurring non-trivial Boolean functions are listed in table 2. The only single gate functions found were for nand (\({\overline{A}}+{\overline{B}}+{\overline{C}}+{\overline{D}}\)), \(n=145\), or (\(A+B+C+D\)), \(n=46\), and and (ABCD), \(n=8\).

Table 2 Top nine highest occurring Boolean functions discovered in experimental laboratory mining with a substrate colonised by living mycelium

4 Discussion

In numerical modelling and experimental laboratory studies we demonstrated that a wide range of Boolean circuits are implemented in a single fungal colony and a substrate colonised by mycelium. In the models where logical functions are implemented with spikes (travelling excitation waves), the xor gate is the rarest, or and and are more common and and-not are most common (select is a rather trivial gate). The frequency distribution of the gate is generally in line with the distributions of gates discovered in other living substrates. In the resistive and capacitive (RC) network model of a single fungal colony, we discovered and-not gate in serial networks, and or and and in parallel networks. This relatively poor representation of logical functions might be due to the absence of capacitive elements. In contrast to the RC model, sets of logical circuits discovered in laboratory experiments with living mycelium are impressively large [27]. This is because living mycelium networks are active, i.e. they generate spikes of electrical potential [5] and spikes of resistance [7], capacitive [12] and memfractive properties [13].