Skip to content

Instantly share code, notes, and snippets.

@kenwebb
Last active August 29, 2015 14:02
Show Gist options
  • Save kenwebb/15e06616cd6e5e0c6417 to your computer and use it in GitHub Desktop.
Save kenwebb/15e06616cd6e5e0c6417 to your computer and use it in GitHub Desktop.
Neuron Diagrams
<?xml version="1.0" encoding="UTF-8"?>
<!--Xholon Workbook http://www.primordion.com/Xholon/gwt/ MIT License, Copyright (C) Ken Webb, Sun Jun 15 2014 09:51:32 GMT-0400 (EDT)-->
<XholonWorkbook>
<Notes><![CDATA[
Xholon
------
Title: Neuron Diagrams
Description:
Url: http://www.primordion.com/Xholon/gwt/
InternalName: 15e06616cd6e5e0c6417
Keywords:
My Notes
--------
According to Martin Erwig and Eric Walkingshaw:
`Modern philosophers have developed several different notations for discussing causation and analyzing causal relationships. The most widely used of these are neuron diagrams, which are created using a domain-specific visual language for concisely representing causal structures.`[1]
`A neuron diagram is a directed, acyclic graph (DAG), where each node is called a neuron. A neuron can either fire or not, which is indicated visually by the color of the node: either gray or white, respectively. Neurons are highly abstract and do not generally represent biological neurons. They are frequently used to represent all sorts of other real world entities, however, from events — where firing indicates the occurrence of the event and non-firing indicates its failure to occur — to the (binary) state of various objects.`[1]
`Neurons in a diagram can be separated into two groups. A neuron with no incoming edges (a source node in the DAG) is called exogenous, and its value (whether or not it fires) is predefined. A neuron that is not exogenous is said to be endogenous, and its value is determined by the values of its predecessors, according to some function.`[1]
`Neurons can be connected by two different types of edges. Edges with triangular arrowheads are stimulating edges, those with circular arrowheads are inhibiting edges. A typical endogenous neuron fires if and only if it is stimulated by at least one firing neuron, and inhibited by zero firing neurons.`[1]
` it is common for creators of neuron diagrams to use or invent neurons which implement other functions as well. `[1]
Erwig and Walkingshaw present several simple thought experiments as examples, including `the well-known desert traveler problem`:
`A traveler goes on a trip through the desert and takes a bottle of water. Two people try to kill the traveler: the first poisons the water while the second pokes a hole in the bottle. On the trip the traveler gets thirsty, tries to drink from the bottle, finds it empty, and dies of dehydration. The problem, of course, is what is the cause of the traveler’s death? Who is guilty of murder? A neuron diagram for the desert traveler problem is given in Figure 1.`[1]
In this workbook I try to implement the desert traveler problem using Xholon and Graphviz.
The neuron diagram does not include the three people mentioned in the problem statement. Nor does it include the bottle of water. A Xholon model typically does explicitly include these sorts of things.
The neuron diagram is a much more terse representation, that focuses exclusively on issues of causation. It's somewhat similar to a sequence diagram in it's inclusion of a time element.
Possibly I can have the three people nodes create the elements of the neuron diagram while the Xholon app is running. When the app stops, it can create the visual neuron diagram using Graphviz and SVG. I can use probabilities to determine the exact order of the people's actions.
The simplest way to generate the Neuron Diagram, is to manually insert the five neurons, and then export the CausalStructure node using Graphviz. Here's the result, complete with generated comments:
/*
Automatically generated by Xholon version 0.8.1, using org.primordion.ef.Xholon2Graphviz.java
Sun Jun 15 08:38:50 GMT-400 2014 1402835930030
model: Neuron Diagrams
www.primordion.com/Xholon
To view this file, use Graphviz dot|fdp|neato|twopi|circo|sfdp from http://www.graphviz.org/
For example, to generate an SVG file:
dot -Tsvg -O CausalStructure_42_1402835930030.gv
Alternatively try one of these:
dot -Tsvg -O CausalStructure_42_1402835930030.gv
dot -Tsvg -O -Grankdir=LR CausalStructure_42_1402835930030.gv
fdp -Tsvg -O CausalStructure_42_1402835930030.gv
neato -Tsvg -O CausalStructure_42_1402835930030.gv
circo -Tsvg -O CausalStructure_42_1402835930030.gv
Or use one of: -Tgif -Tjpg -Tpdf -Tpng -Txdot -Txlib
See also: http://hughesbennett.net/Graphviz
See also: http://graphviz-dev.appspot.com/
See also: http://www.webgraphviz.com/
See also: http://rise4fun.com/agl/
To repeat this Xholon export:
$wnd.xh.xport("Graphviz", $wnd.xh.root().parent().xpath("Chameleon/ThoughtExperimentSystem/CausalStructure"), '{"gvFileExt":".gv","gvGraph":"digraph","layout":"dot","edgeOp":"->","gvCluster":"","shouldShowStateMachineEntities":false,"nameTemplateNodeId":"^^^^i^","nameTemplateNodeLabel":"R^^^^^","shouldQuoteLabels":true,"shouldShowLinks":true,"shouldSpecifyLayout":false,"maxLabelLen":-1,"shouldColor":true,"defaultColor":"#808080","shouldSpecifyShape":true,"shape":"ellipse","shouldSpecifySize":true,"size":"6","shouldSpecifyFontname":true,"fontname":"arial","shouldSpecifyArrowhead":false,"arrowhead":"vee","shouldSpecifyStylesheet":true,"stylesheet":"Xholon.css","shouldSpecifyRankdir":true,"rankdir":"LR","shouldDisplayGraph":true,"outputFormat":"svg"}');
*/
digraph 42 {
graph [label="CausalStructure",id="CausalStructure",stylesheet="Xholon.css",rankdir=LR,size=6,fontname=arial]
node [style=filled,fillcolor="#808080",shape=ellipse,fontname=arial]
43 [label="Poison" id="CausalStructure/Neuron[@roleName='Poison']"]
44 [label="Poke" id="CausalStructure/Neuron[@roleName='Poke']"]
45 [label="Drink" id="CausalStructure/Neuron[@roleName='Drink']"]
46 [label="Thirst" id="CausalStructure/Neuron[@roleName='Thirst']"]
47 [label="Dead" id="CausalStructure/Neuron[@roleName='Dead']"]
}
I then used the http://www.webgraphviz.com/ site to edit the Graphviz DOT content, and generate an SVG image. Here's the DOT content, which is a straight-forward enhancement of the above Xholon-generated code:
digraph 42 {
graph [label="Causal Structure",id="CausalStructure",stylesheet="Xholon.css",rankdir=LR,size=6,fontname=arial]
node [style=filled,fillcolor="#808080",shape=ellipse,fontname=arial]
43 [label="Poison" id="CausalStructure/Neuron[@roleName='Poison']"]
44 [label="Poke" id="CausalStructure/Neuron[@roleName='Poke']"]
45 [label="Drink" id="CausalStructure/Neuron[@roleName='Drink']" fillcolor="white"]
46 [label="Thirst" id="CausalStructure/Neuron[@roleName='Thirst']"]
47 [label="Dead" id="CausalStructure/Neuron[@roleName='Dead']"]
43 -> 45 -> 47
44 -> 46 -> 47
44 -> 45 [arrowhead=dot]
}
I've added the generated SVG to the SVG editor in this workbook.
References
----------
(1) http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.172.9896
@MISC{Erwig_causalreasoning,
author = {Martin Erwig and Eric Walkingshaw},
title = {Causal Reasoning with Neuron Diagrams },
year = {}
}
(2) http://plato.stanford.edu/entries/causation-metaphysics/
Schaffer, Jonathan, "The Metaphysics of Causation", The Stanford Encyclopedia of Philosophy (Summer 2014 Edition), Edward N. Zalta (ed.), forthcoming URL = <http://plato.stanford.edu/archives/sum2014/entries/causation-metaphysics/>.
(3) http://en.wikipedia.org/wiki/Causality
]]></Notes>
<_-.XholonClass>
<!-- terminology from the philosophy domain -->
<ThoughtExperimentSystem/>
<CausalStructure/>
<Neuron/>
<!-- terminology from the desert traveller domain -->
<Person>
<Traveler/>
<Poisoner/>
<Poker/>
</Person>
<People/>
<Bottle/>
<Water/>
<Hole/>
<Poison/>
</_-.XholonClass>
<xholonClassDetails>
<Traveler>
<port name="port" index="0" connector="../../Bottle"/>
</Traveler>
<Poisoner>
<port name="port" index="0" connector="../../Bottle/Water"/>
</Poisoner>
<Poker>
<port name="port" index="0" connector="../../Bottle"/>
</Poker>
</xholonClassDetails>
<ThoughtExperimentSystem roleName="Desert traveller problem">
<Bottle>
<Water/>
</Bottle>
<People>
<Traveler/>
<Poisoner/>
<Poker/>
</People>
<CausalStructure> <!-- created at run time; Neuron Diagram is a visual representation of the causal structure -->
<Neuron roleName="Poison"/>
<Neuron roleName="Poke"/>
<Neuron roleName="Drink"/>
<Neuron roleName="Thirst"/>
<Neuron roleName="Dead"/>
</CausalStructure>
</ThoughtExperimentSystem>
<Poisonerbehavior implName="org.primordion.xholon.base.Behavior_gwtjs"><![CDATA[
var poisoner;
var beh = {
postConfigure: function() {
poisoner = this.cnode.parent();
},
act: function() {
poisoner.println("I am poisoning the water.");
}
}
]]></Poisonerbehavior>
<Pokerbehavior implName="org.primordion.xholon.base.Behavior_gwtjs"><![CDATA[
var poker;
var beh = {
postConfigure: function() {
poker = this.cnode.parent();
},
act: function() {
poker.println("I am poking a hole in the water bottle.");
}
}
]]></Pokerbehavior>
<Travelerbehavior implName="org.primordion.xholon.base.Behavior_gwtjs"><![CDATA[
var traveler;
var beh = {
postConfigure: function() {
traveler = this.cnode.parent();
},
act: function() {
traveler.println("I am traveling in the desert with a bottle of water.");
}
}
]]></Travelerbehavior>
<SvgClient><Attribute_String roleName="svgUri"><![CDATA[data:image/svg+xml,
<svg width="300pt" height="123pt" viewBox="0.00 0.00 300.00 122.80" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g id="CausalStructure" class="graph" transform="scale(1 1) rotate(0) translate(4 118.8)">
<title>42</title>
<polygon fill="white" stroke="white" points="-4,5 -4,-118.8 297,-118.8 297,5 -4,5"></polygon>
<text text-anchor="middle" x="146" y="-8.2" font-family="arial" font-size="14.00">Causal Structure</text>
<!-- 43 -->
<g id="CausalStructure/Neuron[@roleName='Poison']" class="node"><title>43</title>
<ellipse fill="#808080" stroke="black" cx="41" cy="-96.8" rx="40.606" ry="18"></ellipse>
<text text-anchor="middle" x="41" y="-92.6" font-family="arial" font-size="14.00">Poison</text>
</g>
<!-- 45 -->
<g id="CausalStructure/Neuron[@roleName='Drink']" class="node"><title>45</title>
<ellipse fill="white" stroke="black" cx="153" cy="-96.8" rx="33.6247" ry="18"></ellipse>
<text text-anchor="middle" x="153" y="-92.6" font-family="arial" font-size="14.00">Drink</text>
</g>
<!-- 43&#45;&gt;45 -->
<g id="CausalStructure_edge2" class="edge"><title>43-&gt;45</title>
<path fill="none" stroke="black" d="M81.7125,-96.8C90.5588,-96.8 99.9783,-96.8 108.952,-96.8"></path>
<polygon fill="black" stroke="black" points="109.22,-100.3 119.22,-96.8 109.22,-93.3001 109.22,-100.3"></polygon>
</g>
<!-- 44 -->
<g id="CausalStructure/Neuron[@roleName='Poke']" class="node"><title>44</title>
<ellipse fill="#808080" stroke="black" cx="41" cy="-42.8" rx="33.0836" ry="18"></ellipse>
<text text-anchor="middle" x="41" y="-38.6" font-family="arial" font-size="14.00">Poke</text>
</g>
<!-- 44&#45;&gt;45 -->
<g id="CausalStructure_edge8" class="edge"><title>44-&gt;45</title>
<path fill="none" stroke="black" d="M66.14,-54.6505C81.9349,-62.4044 102.75,-72.6228 119.93,-81.0564"></path>
<ellipse fill="black" stroke="black" cx="123.946" cy="-83.0278" rx="4.00002" ry="4.00002"></ellipse>
</g>
<!-- 46 -->
<g id="CausalStructure/Neuron[@roleName='Thirst']" class="node"><title>46</title>
<ellipse fill="#808080" stroke="black" cx="153" cy="-42.8" rx="35.3489" ry="18"></ellipse>
<text text-anchor="middle" x="153" y="-38.6" font-family="arial" font-size="14.00">Thirst</text>
</g>
<!-- 44&#45;&gt;46 -->
<g id="CausalStructure_edge5" class="edge"><title>44-&gt;46</title>
<path fill="none" stroke="black" d="M74.1123,-42.8C84.5994,-42.8 96.4377,-42.8 107.66,-42.8"></path>
<polygon fill="black" stroke="black" points="107.737,-46.3001 117.737,-42.8 107.737,-39.3001 107.737,-46.3001"></polygon>
</g>
<!-- 47 -->
<g id="CausalStructure/Neuron[@roleName='Dead']" class="node"><title>47</title>
<ellipse fill="#808080" stroke="black" cx="258" cy="-69.8" rx="34.2259" ry="18"></ellipse>
<text text-anchor="middle" x="258" y="-65.6" font-family="arial" font-size="14.00">Dead</text>
</g>
<!-- 45&#45;&gt;47 -->
<g id="CausalStructure_edge3" class="edge"><title>45-&gt;47</title>
<path fill="none" stroke="black" d="M183.516,-89.0629C193.984,-86.3188 205.944,-83.1837 217.131,-80.2511"></path>
<polygon fill="black" stroke="black" points="218.337,-83.5533 227.123,-77.6319 216.562,-76.782 218.337,-83.5533"></polygon>
</g>
<!-- 46&#45;&gt;47 -->
<g id="CausalStructure_edge6" class="edge"><title>46-&gt;47</title>
<path fill="none" stroke="black" d="M184.625,-50.8278C194.885,-53.5175 206.477,-56.5561 217.328,-59.4005"></path>
<polygon fill="black" stroke="black" points="216.465,-62.7924 227.025,-61.9426 218.24,-56.0212 216.465,-62.7924"></polygon>
</g>
</g>
</svg>
]]></Attribute_String><Attribute_String roleName="setup">${MODELNAME_DEFAULT},${SVGURI_DEFAULT}</Attribute_String></SvgClient>
</XholonWorkbook>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment