# Simplify boolean expressions using WolframAlpha

When browsing through legacy code, or even when writing my own, I sometimes come across tests which seem uselessly elaborated, and in those occasion, I cannot resist the temptation: I grab a paper and draft some boolean algebra. The most time-consuming part is usually drawing my truth table to make sure I made no mistake while simplifying my tests…

I just thought I would write a program to perform those simplifications. Coding basic simplification rules from boolean algebra seemed quite simple if I used Tom, for instance. Never found the time though. Luckily, if you wish to skip the paper part and get quicker results, you can use WolframAlpha

# The discovery

Half a month ago, I had drafted some algebra and expression reduction, and googled a little to find a check tool. I found a widget on a website, and after digging a little, understood it was pointing directly to WolframAlpha, so I just tested my query onto the engine, and… Hallelujah, it worked!

Here’s how!

# The basics

Let’s take the example of the expression given above, in the upper-left truth table. It reads as follows:
$(A+C).B+\overline{C}$ or if you prefer this notation: $(A\lor{}C)\wedge{}B\lor{}\neg{C}$

Just head to WolframAlpha and enter it in the search field: (A OR C) AND B OR NOT C. You will have a quite complete result page, including this most interesting section:

As you can see, I was not wrong with my own calculation…

# What if your minimal forms differ?

When I discovered this capability with WolframAlpha, I was working with a more complicated expression, and Wolfram was returning a more complicated form than my minimal form. The ideal would have been to compare the truth tables. Which is just what I did.

To do this, you just have to enter all the expressions you wish to compare, separating them with a comma or using the keyword VERSUS or VS. For instance, still taking the same truth table as an example, you can click here to see the result page.

And a quick look at the truth table will prove the equality of both expressions:

That is also quite practical if you want to make sure you made no mistake.

Really, everything you need is somewhere on the web already. Now, maybe I’ll just dive into my boolean simplificator when I have the time, just for the challenge of it. Or rather, for the fun of it. ðŸ™‚