### misc: if-then machine

```
if-then machine:
description:
if-then machine
a simplified model of a neuron
the general idea is that each "neuron" has a collection of sequences
and if any of them match the input, that "neuron" triggers, and activates its' "then" rule
the output rule doesn't have to be just a literal ket/superposition/sequence
it could also be a stored rule, and perform any desired function
the coefficients of the output superposition are multiplied by the similarity of the input with the matched pattern
if more than one pattern on an if-then machine matches, the coefficient could be larger than 1
if this is not desired, you could for example use "clean" or "sigmoid-min[1]"
the eventual goal is to have many layers of if-then machines processing some given input

examples:
-- the structure of a single if-then machine:
pattern |node: 1: 1> => seq1
pattern |node: 1: 2> => seq2
...
pattern |node: 1: n> => seqn
then |node: 1: *> => output-sp

-- let's define an abstract example:
-- basically detect small fragments of the alphabet
-- either in superposition or in sequence form
pattern |node: 1: 1> => split |abc>
pattern |node: 1: 2> => ssplit |abc>
then |node: 1: *> => |found: abc>

pattern |node: 2: 1> => split |uv>
pattern |node: 2: 2> => ssplit |uv>
then |node: 2: *> => |found: uv>

pattern |node: 3: 1> => split |xyz>
pattern |node: 3: 2> => ssplit |xyz>
then |node: 3: *> => |found: xyz>

-- now define the back-end operator:
-- the drop-below[0.5] is to remove matches with less than 50% similarity
if-then (*) #=> then drop-below[0.5] similar-input[pattern] |__self>

-- now take a quick look at what we know:
sa: dump
------------------------------------------
|context> => |Global context>

pattern |node: 1: 1> => |a> + |b> + |c>
pattern |node: 1: 2> => |a> . |b> . |c>
then |node: 1: *> => |found: abc>

pattern |node: 2: 1> => |u> + |v>
pattern |node: 2: 2> => |u> . |v>
then |node: 2: *> => |found: uv>

pattern |node: 3: 1> => |x> + |y> + |z>
pattern |node: 3: 2> => |x> . |y> . |z>
then |node: 3: *> => |found: xyz>

if-then (*) #=> then drop-below[0.5] similar-input[pattern]|__self>
------------------------------------------

-- now some examples:
-- let's input xyz as a superposition:
if-then split |xyz>
|found: xyz>

-- now as a sequence:
if-then ssplit |xyz>
|found: xyz>

-- once again, this time input uv as a superposition:
if-then split |uv>
|found: uv>

-- now as a sequence:
if-then ssplit |uv>
|found: uv>

-- now matching partial superpositions and sequences:
if-then split |bc>
0.666667|found: abc>

if-then ssplit |ab>
0.666667|found: abc>

similar-input, strict-similar-input, equal-input, drop-below, identify-and-predict-integer-sequence-fragments.sw3

```
Home