Sign up ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I have become fascinated with Randolph Diagrams and was wondering how we would create the diagrams from logical sequences using Mathematica?

It looks like it would be a combination of logic and graphing. I have no idea where to start. I need some suggestions to get me going.

Edit: Randolph's paper on JStor

share|improve this question

1 Answer 1

up vote 22 down vote accepted

This could provide a good starting point, since the structure of the diagrams is simply a cross with four regions that themselves can contain similar crosses, you can simply define a structure to represent this nesting and a recursive function to draw such structures. In my implementation I just use the head c to indicate a cross:

dirs = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};

cross[mid_, scale_] := {
 Thickness[0.02 scale],
 Line[{scale {-1, -1} + mid, scale {1, 1} + mid}],
 Line[{scale {1, -1} + mid, scale {-1, 1} + mid}]

rDraw[True, mid_, scale_] := Disk[mid, scale]
rDraw[False, ___] := {}
rDraw[c[a__], mid_: {0, 0}, scale_: 1] := {cross[mid, scale], 
 Sequence @@ MapIndexed[
   rDraw[#1, mid + scale  dirs[[#2[[1]]]], 0.45 scale] &, {a}]}

So then you can create a diagram via:

With[{t = True, f = False},
 rDraw@c[t, f, c[f, c[f, t, c[f, t, f, t], f], t, f], f] // Graphics

an image showing a diagram plot

Now it is just a question of converting expressions like (A&B) or !C into this c[...] structure.

Here's a small graph of some simple operations:

With[{t = True, f = False},
 Graphics[rDraw[#2], PlotLabel -> #1] & @@@ {
    {"and", c[f, t]},
    {"Nand", c[t, f, t, t]},
    {"or", c[t, t, t]},
    {"Nor", c[f, f, f, t]}
    } // GraphicsRow

Simple operations diagrams

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.