32leaves.net

Cellular automaton again

As we were doing some logic during the last few lectures (see the post about reasoner), I decided that I wanted to do something usefull with this highly interessting stuff. So as I already had an engine to evaluate propositional logic expressions it was an easy thing to accomplish the following idea:
Consider the following matrix constituting our “world” and initial population:

    \[F = \begin{pmatrix} c_{11} & \dots & c_{1j} \\ \vdots & \ddots & \vdots \\ c_{n0} & \dots & c_{nn} \end{pmatrix}\]

with

    \[c_{ij} \in \{0,1\}\]

and

    \[i,j \in [1,n]\]

To compute a new “generation” the aliveness (1 being alive, 0 dead) of each element is determined by evaluating a certain propsitional expression:

    \[c_{ij,\mbox{new}} = E(\beta)\]

with

    \[\beta\]

being the valuation of the proposition and

    \[E\]

being the proposition itself.

    \[\beta \rightarrow \{\top,\bot\}\]

    \[\beta(a) \mapsto c_{ij} = 1\]

    \[\beta(a_n) \mapsto f(i, j) = n\]

with

    \[f(u, v) = \sum^{u + 1}_{u - 1}\sum^{v + 1}_{v - 1}c_{uv} - c_{ij}\]

Have a look at the screenshot to get a better idea on what the program is doing or run it using Java webstart below (may not work on MacOSX or Windows).

Launch using webstart


Practicing binary addition

Today we we’re talking about binary addition and the twos complement. As our professor really sets a high value on being able to do binary addition and to calculate the twos complement, I decided write a small program to aid practicing those two. Click here to get this started.

Once you’ve filled in all the missing fields (or hit the help me link) hit return to see whether you’ve been right or not.

Reasoner – downloads available

As I announced yesterday, the reasoner downloads are now available. For now only binary, but the sources will follow:

Linux
MacOSX
Windows (untested)
Windows WPF (untested)

They’re all roughly 15mb big and you’ll need at least JRE 1.5 to run them. Have fun and if you have any questions or problems, feel free to post in the comments.

Reasoner – Playing with boolean expressions

One of my lectures deals with mathematical logic. In order to play around with this highly interessting topic I wrote a small program dealing with this. The program is able to

  • compute thruth tables
  • evaluate expressions with custom input
  • render syntax graphs
  • check if an expression is satisfiable or a tautology
  • Normalize expressions to CNF or DNF

The following operators are allowed:

  • &

    : AND

  • |

    : OR

  • ->

    : SUBJUNCTION

  • <->

    : BIJUNCTION

  • !

    : NOT

You may use lower case characters suffixed with integer numbers (e.g.

a, b, c2, d-3

)

Example:

1
2
3
4
5
/**
 * This is just a test
 */

(((a & b ) -> ((c | (a & c)) <-> d)) & a) <-> (a & (a <-> (b | c)))

Be aware that as I’m just beginning diving into this field all algorithms implemented in this application are NP complete. Meaning that the time it takes to compute certain things grows exponentially to the amount of distinct atoms (e.g. computing a truth tabe for

1
a & b

is way faster than for

1
a & b & c & d & e & f & g & h & i & j & k & l & m & n & o & p & q & r & s & t & u & v & w & x & y & z

which produces 67108864 rows).
The program runs on Windows, MacOSX and Linux. Alltough I didn’t test Windows (cauz’ I don’t have that “operating system” running anywhere). I’ll publish the binaries and source as soon as I have access to the University network tomorrow (where I have enough space left to do so).

Demo Video

Fork me on GitHub