Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Simplify boolean expression algorithm

Anybody knows of an algorithm to simplify boolean expressions?

I remember the boolean algebra and Karnaught maps, but this is meant for digital hardware where EVERITHING is boolean. I would like something that takes into account that some sub-expressions are not boolean.

For example:

a == 1 && a == 3

this could be translated to a pure boolean expression:

a1 && a3 

but this is expression is irreducible, while with a little bit of knowledge of arithmetics everibody can determine that the expression is just:

false

Some body knows some links?

like image 288
Olmo Avatar asked Mar 15 '11 11:03

Olmo


People also ask

What is Boolean expression in algorithm?

In computer science, a Boolean expression is an expression used in programming languages that produces a Boolean value when evaluated. A Boolean value is either true or false.

Why do we simplify Boolean expressions?

There are many benefits to simplifying Boolean functions before they are implemented in hardware. A reduced number of gates decreases considerably the cost of the hardware, reduces the heat generated by the chip and, most importantly, increases the speed.


2 Answers

You might be interested in K-maps and the Quine–McCluskey algorithm.

I think SymPy is able to solve and simplify boolean expressions, looking at the source might be useful.

like image 108
Benjamin Avatar answered Oct 02 '22 16:10

Benjamin


Your particular example would be solved by an SMT solver. (It'd determine that no setting of the variables could make the expression true; therefore it's always false. More-general simplification is out of scope for such solvers.) Showing that an expression is equivalent to true or false is of course NP-hard even without bringing arithmetic into the deal, so it's pretty cool that there's practical software for even this much. Depending on how much arithmetic knowledge is in scope, the problem may be undecidable.

like image 29
Darius Bacon Avatar answered Oct 02 '22 16:10

Darius Bacon