123

I was refactoring old code and encountered several IF conditions that were way too complex and long and I'm certain they can be simplified. My guess is that those conditions grew so much because of later modifications.

Anyway, I was wondering if any of you know of a good online simplifier I can use. I'm not interested in any specific language, just a simplifier that would take in for example:

((A OR B) AND (!B AND C) OR C)

And give me a simplified version of the expression, if any.

I've looked at the other similar questions but none point me to a good simplifier.

Thanks.

mojarras
  • 1,624
  • 2
  • 11
  • 9
  • 1
    WolframAlpha also arrives at *C*. No extra gates ... – Axel Kemper Oct 08 '13 at 12:25
  • 1
    There's a nice online tool - http://tma.main.jp/logic/index_en.html – Roman Hocke May 18 '17 at 06:53
  • Another tool is [boolean-algebra.com](https://www.boolean-algebra.com) it will show the steps to solve it. For example, yours can be solved with just the absorption law A+AB = A. It's not too advanced so if you need something other than minimal form then you better use another site. – John Smith Oct 14 '19 at 18:59
  • This question should have been posted on https://softwarerecs.stackexchange.com/ instead of Stack Overflow. – Anderson Green Nov 22 '22 at 16:57

3 Answers3

100

You can try Wolfram Alpha as in this example based on your input:

http://www.wolframalpha.com/input/?i=((A%20OR%20B)%20AND%20(NOT%20B%20AND%20C)%20OR%20C)&t=crmtb01&f=rc

DanBlakemore
  • 2,306
  • 2
  • 20
  • 23
  • 4
    The website doesn't seem that good for simplifying boolean formula's when they get a bit more complex. Try this one: (((NOT C) AND (NOT A)) OR ((NOT B) AND (NOT C) AND (NOT D) AND (NOT A)) OR ((NOT B) AND (NOT C) AND D AND A) OR (B AND C AND (NOT D) AND (NOT A)) OR (B AND C AND D AND A)) – Albert Hendriks Mar 18 '16 at 07:38
  • 2
    Indeed. Strange. It even barfs at the simplified version `NOT C AND NOT A OR NOT B AND NOT C AND NOT D AND NOT A OR NOT B AND NOT C AND D AND A OR B AND C AND NOT D AND NOT A OR B AND C AND D AND A`. – 500 - Internal Server Error Mar 18 '16 at 15:33
  • 2
    Note that if you want the truth table, which is not always outputed for some expressions, then start the query with the words "truth table" followed by the expression – Belgi May 20 '17 at 13:00
17

Try Logic Friday 1 It includes tools from the Univerity of California (Espresso and misII) and makes them usable with a GUI. You can enter boolean equations and truth tables as desired. It also features a graphical gate diagram input and output.

The minimization can be carried out two-level or multi-level. The two-level form yields a minimized sum of products. The multi-level form creates a circuit composed out of logical gates. The types of gates can be restricted by the user.

Your expression simplifies to C.

Axel Kemper
  • 10,544
  • 2
  • 31
  • 54
  • 2
    For a quick online tool this is really helpful: http://tma.main.jp/logic/index_en.html – Lenar Hoyt Apr 06 '17 at 00:33
  • There are some computer algebra systems that can simplify boolean expressions using the Quine-McCluskey algorithm, such as [Sympy](https://docs.sympy.org/latest/modules/logic.html). – Anderson Green Oct 25 '20 at 21:05
  • 1
    [Quine-McCluskey](https://en.wikipedia.org/wiki/Quine%E2%80%93McCluskey_algorithm) is the grandfather of two-level minimization.[Espresso](https://en.wikipedia.org/wiki/Espresso_heuristic_logic_minimizer) came 30 years later in 1986. It would be interesting to learn about recent developments in this field. – Axel Kemper Oct 25 '20 at 23:03
8

I found that The Boolean Expression Reducer is much easier to use than Logic Friday. Plus it doesn't require installation and is multi-platform (Java).

Also in Logic Friday the expression A | B just returns 3 entries in truth table; I expected 4.

Pawel Dubiel
  • 18,665
  • 3
  • 40
  • 58
  • 3
    Activate option "Truthtable/Show all Rows" in Logic Friday 1. Otherwise, you only get all rows with output value 1. – Axel Kemper Dec 16 '13 at 08:13
  • 1
    Internally, bexpred is using simple algorithms to merge minterms. It might be helpful for small expressions but is definitely not state-of-the-art. – Axel Kemper Sep 23 '15 at 16:11
  • 3
    For "A\*B\*(!A\*B+!A\*!B)" input this jar returns SOP False but POS True. Not exactly reliable script... – Evil Dec 07 '16 at 03:41
  • link is broken, who has a working link? – HJLebbink Dec 06 '17 at 11:29