3

can anyone recommend software (preferably for mac) or a web based tool, that can be used to evaluate logic expressions?

For example I would like to be able to quickly test whether two expressions like:

$a = 'foo';
$b = 'bar';
$c = 'foo';

( !(($a == $c) && ($b == $c)) )

// and

( ($a != $c) || ($b != c$) )

are interchangeable or not.

And also, is there generally an agreed upon best practice in relation to how to construct such expressions? For example to try to minimize the use of the negation, the order of the elements or something like that?

Sometimes I find myself struggling a bit with these things :)

mikkelbreum
  • 3,021
  • 9
  • 38
  • 41

3 Answers3

5

You can also use Wolfram Alpha

https://www.wolframalpha.com/input/?i=P+%26%26+(Q+%7C%7C+R)&lk=3

or

https://www.dcode.fr/boolean-expressions-calculator

Revious
  • 7,816
  • 31
  • 98
  • 147
0

You can use something like http://www-cs-students.stanford.edu/~silver/truth/ and compare the generated truth tables.

Paweł Obrok
  • 22,568
  • 8
  • 74
  • 70
  • thanks thats useful, but it requires a bit of work though. If I understood it correctly, I had to rewrite my examples like: (a & b) and (a | b) and then compare those truth tables, and negate the output of the latter myself. but once I've done that work, I've already done what I try to avoid. I'd like to be able to set input a string like the one in my example directly. – mikkelbreum Jul 21 '11 at 12:57
0

I like this site which does exactly what you are looking for, but it only supports limited logical operators: https://electronics-course.com/boolean-algebra

Amith Kumar
  • 4,400
  • 1
  • 21
  • 28