布尔代数 - 如何化简

Boolean Algebra - How to Simplify

在 JS 工作,刚开始学习布尔代数。想知道是否有办法简化这个表达式:

(!variableOne || !variableTwo)

我记得听说过两个 'nots' 意味着你可以更改符号,但是当我 google 'boolean algebra'.

谢谢!

你可以 De Morgan's laws:

!(a && b) = !a || !b 
!(a || b) = !a && !b

你的情况是

!(variableOne && variableTwo)

De'Morgans Law 所说,您可以将 !a || !b 转换为 !(a && b)

所以你可以 !(variableOne && variableTwo)

回答晚了,但要进一步解释:

  • The negation of an and statement is logically equivalent to the or statement in which each component is negated.

象征性地: !(A && B) = !A || !B

  • The negation of an or statement is logically equivalent to the and statement in which each component is negated.

象征性地: !(A || B) = !A && !B

在你的例子中你使用了 !variableOne || !variableTwo 所以它等同于第一定律 !(variableOne && variableTwo) == !variableOne || !variableTwo.