How to understand De Morgan Laws Boolean Expression

前端 未结 2 2126
旧时难觅i
旧时难觅i 2020-12-07 02:50

I got screwed when trying to understand this expression. I\'ve thought several times but I cant get the meaning.

  1. ! (p || q) is equivalent to !p && !

相关标签:
2条回答
  • 2020-12-07 03:24

    Think of it in terms of the Red Toyota.

    Let p = "The car is red"

    Let q = "The car is a Toyota"

    ! ( p && q ) means "The car is not a red Toyota"

    Which is the same as saying:

    !p || !q "it's not red, or (inclusive) it's not a Toyota" , right?

    0 讨论(0)
  • 2020-12-07 03:43

    You can use a Truth table to see how the two expressions are equal. Like This:

    
    !(P || Q) = !P && !Q 
    
    _________________________________________________
       P   Q   P || Q   !(P||Q)   !P   !Q   !P && !Q
    _________________________________________________
       1   1      1         0      0    0       0
       1   0      1         0      0    1       0
       0   1      1         0      1    0       0
       0   0      0         1      1    1       1
    _________________________________________________
    

    Note that the column labeled !(P||Q) is the same as the column labeled !P && !Q. You can work this from the left most column where we set the initial values for P and Q. Then work out each column towards the right.

    
    !(P && Q) = !P || !Q 
    
    _________________________________________________
       P   Q   P && Q   !(P&&Q)   !P   !Q   !P && !Q
    _________________________________________________
       1   1      1         0      0    0       0
       1   0      0         1      0    1       1
       0   1      0         1      1    0       1
       0   0      0         1      1    1       1
    _________________________________________________
    
    
    
    0 讨论(0)
提交回复
热议问题