This repository contains files related to RnD Project (Autumn 2023).
The definition and functioning of nerve nets, as implemented in this repository, is aligned with that of the book 'Counter-Free Automata' by McNaughton and Papert, which is accessible via the Internet Archive at this link. Note that the definition(s) from other sources could differ (e.g. an inclusion of implicit neuron delay) but such nerve nets can also be simulated here with suitable modifications in the inputs. (We have picked the more malleable definition.)
- You can edit input file path in the file
config.json
, and also enter the input string there. (An example is explained below.) Theverbose_roundwise
option allows you to view the internal junction/neuron values at each timeslot. - Run
python3 src/simulator.py
to simulate the nerve net and print output at the time of the last input character(s) being sent into the system. sandbox/
contains code that consists of snippets dealing with graphical approach, dictionary separation, etc.
Input files must be of the following format:
- Line 1: Number of input lines (I1, I2, ...)
- Line 2: Number of output lines (O1, O2, ...)
- Line 3: Number of neurons (1, 2, ...)
- Line 4: Threshold values for neurons ordered by neuron ID
- Line 5 onwards: Axon specifications, in the format:
<start-point> <end-point> <delay> <nature>
where:<start-point>
can be a neuron or an input line.<end-point>
can be a neuron or an output line.<delay>
is a non-negative integer.<nature>
is either 0 (inhibitory) or 1 (excitory).
Ensure that the nerve net is well-formed (i.e., it has no zero-delay loops), or the program may enter an infinite loop (as it should, in that case).
A buzzer net is represented by the following figure (Assume that the input line is I1
, and that output O1
is the value on the feedback axon just before the delay element):
For this example, config.json
is specified as:
Here, the attribute I1
denotes the input stream incident to input line I1
. Also, the contents of inputs/buzzer.in
specify the buzzer net as follows:
With "verbose_roundwise": true
, and "I1": "11111"
, on running python3 src/simulator.py
the following output is observed, depicting the values of the neurons, axons, and I/O lines:
Note that the event at O1
is denoted by {"O1": 1}
as the final output, signifying acceptance/occurrence of the desired event.
If the same were to be run with the string 1111
as input on I1
, then the same output trace would be generated EXCEPT the last timeslot. Hence, {"O1": 0}
would signify the string not being accepted.
The file inputs/input2.in
encodes the following nerve net (Assume that B
is I1
, and C
is I2
, while D
is O1
):
For this example, config.json
is specified as:
The encoding is as follows:
For the inputs specified in the above two images, running python3 src/simulator.py
results in the following output:
Clearly, the input strings, and any equal-length prefixes of the inputs are not accepted as high-signal events at O1
. To describe the event at O1
, we assume the following alphabet-encoding: 0 : (C : 0, B : 0); 1 : (C : 0, B : 1); 2 : (C : 1, B : 0); 3 : (C : 1, B : 1), and Σ = {0, 1, 2, 3}. Here, the event at O1
is given by
Let us check the output stream to verify this!
Thus any scenario where the final input is 2 with a 1 or 3 at some point in the prior past is accepted, with {"O1": 1}
at the final timeslot.
- If your nerve net has some amount of 'delay' with respect to its output, the input string must also have extra characters to compensate, since the event described could be something along the lines of
$(0101)^{ *}\Sigma\Sigma$ if the nerve net accepts$(0101)^{ *}$ with a delay of two time slots after the end of the last 'processed' character. Hence, be diligent when entering an input string. - If
verbose_roundwise
is set tofalse
, then the output will just be the value ofO1
at the final timeslot.
"Let your rapidity be that of the wind, your compactness that of the forest." — Sun Tzu, The Art of War