There's so pretty much seemingly unique proprietary software. A while ago I found this awesome logic minimizer called "logic Friday". [1] I don't think there's a free or open source version of a tool like this.
I have an idea that the "espresso" algorithm could be used to minimize not only electronic circuits but general boolean expressions for any programming language... I think it would do for a useful refactoring tool.
It simulates logic, supports automated testing, simulates and analyses combinatorial and sequential logic, comes with a large library of components (generic stuff, specific 7400 logic, displays and memories, etc), it can output VHDL or Verilog, and it can export JEDEC files for GALs.
Quine McCluskey is equivalent to using Karnaugh maps. Both are basic digital logic minimization workflows, and are taught in any course covering digital logic or CS-focused discrete math.
> I have an idea that the "espresso" algorithm could be used to minimize not only electronic circuits but general boolean expressions for any programming language... I think it would do for a useful refactoring tool.
I think the goal for most boolean expressions in code is for the reader to be able to conceptually grasp what's being checked for, not for the expression to be as short as possible. Distributive properties can make an expression shorter while simultaneously making the concepts behind the expression much more obscure.
As a compiler writer I can tell you that this is a complex optimisation with very limited use.
N.B. the || (logical or) operator is an "early out" operator whereas the | (binary or) operator is NOT
The compiler would need to look for special cases of value1, value2 and value3... such as: are any of them volatile, perhaps one refers to a memory mapped I/O device, perhaps one if actually a function call, or array dereference, or pointer dereference, what about value1 being a "char" which needs to be promoted before it can be or'd, what about any of the "values" being a constant < 0 which would short circuit the "if" statement and remove the need for any tests.
As I said, this is not as simple as it first appears.
That optimization fudges the difference between boolean or (comparing truth values) and bitwise or. It happens to work under the safe assumption that value1, value2, and value3 use sign bits (as all two's-complement integers do), but logically it's a disaster.
monocasa isn't saying this should be in source code, but rather the compiler should create machine code that does this. Compilers know the types, so they will know whether they're signed (if they're not signed, then < 0 can be optimized out as impossible). Compilers have no goal of creating assembly that would look good in source code.
Good point, although the idea would be you get to choose one for or the other. I think sometimes the simplified expression makes it easier to see the complement (else branch).
btw, I started to think about "boolean refactoring" when I saw J. Edwards' schematic tables video [1].
I've used Logic Friday once to make a wired remote controller device that operated on 74-logic. I haven't really seen any tools that offer more user-friendly ergonomics for that type of problem, except maybe a curve-fitting tool called Eureqa which used to be open-source and went closed-source. Or perhaps Wolfram Mathematica could be used to spit out a few solutions, again closed-source.
> There's so pretty much seemingly unique proprietary software.
Indeed. Something to consider when choosing a license and distribution model for your own projects, including web-based software. Your life is finite, but the life of your software may not be.
I have an idea that the "espresso" algorithm could be used to minimize not only electronic circuits but general boolean expressions for any programming language... I think it would do for a useful refactoring tool.
1: https://web.archive.org/web/20131022051516/http://www.sontra...