布尔代数 - 为什么不(真和假)是真的?

For*_*cel 0 python boolean boolean-algebra

我正在写这本书"艰难地学习python".在练习27(http://learnpythonthehardway.org/book/ex27.html)中,它以布尔代数开始.

所以我的问题是:为什么是not(True and False)真的?

我是如何理解的,它应该是一样的False and True.

Mar*_*ers 9

您的解释是不正确的,请参阅De Morgan的法律 ; 特别是否定一个连词就是否定的分离.

not (True and False)(否定一个连词 == not(a and b))相当于False or True(一个否定的分离 == (not a) or (not b)); 注意切换andor!

您还可以执行以下步骤:

  • not(True and False)
    • 首先在括号中计算出部分,True and False- >False
  • 将结果替换回表达式:not(False)- > True.


che*_*ner 8

not (True and False)首先简化为not (False),然后进一步简化为True.