Version 1 of Little Circular Networks in Tcl

Updated 2003-07-12 20:24:51

Theo Verelst

Started this page but claims no rights to keep it unchanged, as usual.

Networks are important, end knowing essentials is even important for programming, and in tcl we can quite well explore what happens with data passing through the smallest imaginable networks, to learn to begin with about what computers are essentially made of, further what networking can do, what object message sending limitations and possible errors are about, and what threads and interprocess communication must deal with.

And it's fun enough to think about the quite large complexity involved in a few 'not-so-black' boxes exchanging information, being 'created', initialized, and how one sensibly can simulate or enforce a communication regime to make the network tick.

In ee, you'd have logical circuit simulators who do such things, but if you don't persue a PhD and still want to think about oo messages, this tcl-inside page should not pose insurmountable problems.

I'm sure, by experience of letting a tcl/tk controller socket-talk a number crunching C program in real time, that the issue is relevant (in that context in windows tcl 8.0+ I think with cygnus socket connection).

Lets start with the idea of a logical function, which is easy enough, and of course done on various pages (boolean logic Finite State Machine).

A procedure to make an NAND as being invert(and(a,b):

 proc nand {a b} {return [expr !($a && $b)]}

the result is only 1 when both a and b are 0, and0 otherwise. Now we could put two nands on a row and feed the output back to the input, like we would do for an eigenvalue analysis/definition, and play around with what that gives us:

 proc nand2 {a b} {return [expr !($a2 && $b)]}

 set a 1
 set a2 1

 for {set i 0} {$i < 10} {incr i} {
    set b2 [nand $a $b]
    set b  [nand2 $a2 $b2]
 }
 # or:
 for {set i 0} {$i < 10} {incr i} {
    set b2 [nand $a $b]
    set b  [nand2 $a2 $b2]
 }

So the nands are like in series, and then fed round, and the open inputs are set to 1.

The fun is that this circuit can memorize a bit, also in electronical practice, and that as it is, it is like the dining philosophers, or at least it is as yet undefined what it will do: the above minimal initialisation of the eigenvalue problem leaves us with an undefined initial state, no matter what order we make the nands evaluate in.

Now this might seem a touch boring or irrelevant, but it isn't. Its the eigenfunction analysis of a very simple function composition, which has memory, as we'll see, and which is undefined to start with, but completely defined from any resolving point onward, it is easily controllable, and can be practically implemented in various reasonable ways.

We can break through the undefined loop by applying another input signal to one of the inputs set to one thus far, as soon as we do that, the problem enters a defined state, and it depends on which input we make zero instead of one what state that will be: {b2 b} = 01 or 10.

When we in the 'running' network bring both open inputs back to 1, the last state, which was stable, is remembered. Setting the other input to zero forces the inverse state, while a=0 and a2=0 makes both b and b2 1, which cannot be a situation which is remembered.

For simulation, or practical implementation, it doesn't matter how and when we evaluate the functions, as long as for each input change, both get evaluated sufficiently often to propagate the chance into a new stable overall state.