Simplest algorithm for computing the resultant of a boolean expression?

In summary, the conversation discusses the difficulty of finding an elegant and simple algorithm for computing the truth value of a complex Boolean expression. The problem itself is known to be NP complete, meaning that there is no known algorithm that can solve it in polynomial time. While there may be specific properties that can be used to speed up the process for certain examples, there is no general solution.
  • #1
spikenigma
61
0
hi,

let's take something simple, for example:

(a>b) && ((b>c) && c>d) || (d > c)

Intuitively, it's easy to work out given the values of a, b, c and d and just evaluating the brackets in order of precedence.

i.e.

Is b > c?? then is c > d
Then in addition to the above answer being true is a > b?
Then despite the earlier answer is d > c?
If true return true, if false return false.

But surely there is an elegant, simple algorithm for working this out computationally?

Could you for example take each expression, number them in terms of their evaluation step then evaluate in n steps based on [some factor] to get the answer?

i.e.

1) b>c, and then because of [factor], compute &&
2) c>d, and then because of [factor], compute &&
3) a>b, and then because of [factor], compute ||
4) d > c
5) answer

I know the factor is sign-right or sign-left of the expression and it could be used to create an algorithm.

But has anybody got anything more elegant?
 
Mathematics news on Phys.org
  • #2
The problem itself is NP complete, i.e. no algorithm is known, which decides in polynomial time whether a general Boolean expression is satisfiable or not, see https://en.wikipedia.org/wiki/Boolean_satisfiability_problem. This means in return, that given a certain example, we can probably use specific properties to be faster, but not in general.
 

FAQ: Simplest algorithm for computing the resultant of a boolean expression?

What is a boolean expression?

A boolean expression is a mathematical statement that can only have one of two values: true or false. It is typically used in logic and computer programming to make decisions based on the truth value of the expression.

What is the simplest algorithm for computing the resultant of a boolean expression?

The simplest algorithm for computing the resultant of a boolean expression is the truth table method. This involves listing out all possible combinations of inputs and calculating the output for each combination.

How does the truth table method work?

The truth table method works by creating a table with the variables in the expression as columns. Each row represents a different combination of inputs, and the final column shows the output for that combination. The output is calculated based on the logical operators used in the expression, such as AND, OR, and NOT.

Are there any other algorithms for computing the resultant of a boolean expression?

Yes, there are other algorithms such as the Quine-McCluskey method and the Karnaugh map method. These methods are more efficient for larger boolean expressions, but they require a deeper understanding of boolean algebra.

Can you give an example of using the truth table method to compute the resultant of a boolean expression?

Yes, for the expression (A AND B) OR (NOT C), the truth table would have 3 columns for A, B, and C and 1 column for the output. The rows would be labeled with all possible combinations of inputs (e.g. A = true, B = false, C = true). The output column would be calculated as (true AND false) OR (NOT true) = false OR false = false. This process would be repeated for all rows, resulting in a complete truth table for the expression.

Back
Top