Sitemap

Building Truthful Half-Adders

4 min readOct 9, 2025

--

As we continue our logic lessons on Brilliant.org, we are now on to building digital circuits. Today, we learn how to make a half adder, but I will also go on to show how to create one with Netica (a Bayesian Network).

Project: Building half-adders with Netica
An adder built out of logic gates should have outputs for 1s and 2s with the following truth table.
Press enter or click to view image in full size
Select a logic gate to create the right outputs for the 1s column of the table.

We are given three choices between OR, XOR, and AND so as to produce (0, 1, 1, 0) from the two binary inputs A and B.

Press enter or click to view image in full size
The input node allows us to cycle through all four scenarios

We need some equations:

input (A, B) = 2 * A + B      // maps the boolean node to digits

gate (A, B, select) =

select0 ( select , or (A, B) , xor (A, B), and (A, B) ) // map index to gates

S1 (gate) = gate // the output for 1S

(Note that “S1 (gate) = gate” is just a pass-through to S1)

Equation for input node to cycle through digits
Output according to which logic gate we select

We can already see that XOR is the desired logic gate for the desired output (0, 1, 1, 0).

Let’s watch the network in action as we test each logic gate with the inputs (0, 1, 2, 3) and watch the output S1 on the other side.

Press enter or click to view image in full size
We select a logic & cycle through the inputs (0,1,2,3) and watch the output at S1

We verified that XOR produces the desired output given the inputs.

We do the same thing for output 2S:

Press enter or click to view image in full size
Select a logic gate to create the right outputs for the 2s column of the table.

We can reuse the same network, and indeed, we have already seen the solution. Since the desired output for 2S is (0, 0, 0, 1), we can see that the AND gate will work.

Press enter or click to view image in full size
The AND gate for output 2S

What Brilliant.org does is good as far as it goes, but it simply does not go far enough in my view. In spite of that, I have still been a paying subscriber since 2022 and, on the whole, I have generally been satisfied. But it does not seem to me that these animations they give are nearly as satisfying (and instructive) as what can easily be accomplished by building a digital circuit with a Bayesian network like Netica (or GeNIe, as I show below).

Get Pascal Bercker’s stories in your inbox

Join Medium for free to get updates from this writer.

We can combine the gates to complete the adder:

Press enter or click to view image in full size

Our corresponding network is as follows:

Press enter or click to view image in full size
As we discovered earlier the first logic gate is XOR and the AND gate is the second

Let’s check to see that as we cycle through the inputs (0, 1, 2, 3) that, with the selected gates, we really produce the desired outputs (0, 1, 1, 0) for S1 and (0, 0, 0, 1) for S2 (note that variable names cannot start with a number, hence S1 and S2 instead of 1S and 2S). We will activate the AND gate and the XOR gate (in green) and verify that each input produces the correct output.

Press enter or click to view image in full size
Watch to verify that we get the desired outputs for S1 and S2 given the inputs (0, 1, 2, 3)

At the risk of cluttering things too much, let’s be more explicit about what we have done. We input two binary bits, choose the right set of gates for a half-adder, carry out the logic to add them, and convert the result to a decimal sum.

Press enter or click to view image in full size
Input → A,B → logic gates → bits → numeric sum

The Brilliant.org lesson concludes:

Press enter or click to view image in full size

We have indeed, but I would add this: Once we leave that page on Brilliant.org, the half-adder we have built just disappears along with the page, and there is nothing to take home, as it were. But if instead we really build one with a Bayesian Network like Netica, then, at the end of the day, we have our little half-adder tucked away somewhere on our computer, saved in a file in whatever format we like. (I’m happy to share the file with anyone who asks!)

Just for the sake of interest, I converted the Netica model to a GeNie file format. Here is what it looks like. It has the same basic structure with some minor differences in how it handles equational nodes (but we will ignore that for now).

Press enter or click to view image in full size
We carry out the same verification we did with Netica; we first select the AND gate and the XOR gates, and then check that each input gives the correct output on the right.

What’s next? A full adder, of course!

--

--

Pascal Bercker
Pascal Bercker

Written by Pascal Bercker

Philosophy | philosophy of science | logic | Bayesian networks and logic puzzles | keen on the use of Bayesian networks to solve Smullyan-type logic puzzles