# DeMorgan`s Theorem ```DeMorgan’s Theorem
Objective:
Students will be able evaluate DeMorgan’s’ Theorem.
Background
In logic, De Morgan's laws (or De Morgan's theorem) are rules in formal logic relating
pairs of dual logical operators in a systematic manner expressed in terms of negation. The
relationship so induced is called De Morgan duality. To give some intuition, suppose P is true if
and only if it is raining and Q is true if and only if you are wearing a raincoat . Consider the
following situation- It's not raining, so you don't care whether you're wearing a raincoat or not. In
symbols, this would be written (Not P) or Q
Moreover, DeMorgan’s Theorems can help new programmers develop correct expressions
for if statements. Thus, we can use DeMorgan’s Law to find the logical negation (NOT), or
opposite, of an expression formed with the logical operators &amp;&amp; and ||. There are numerous
identities that deal with compound Boolean expressions. However, DeMorgan's Laws are use
usfful negate compound Boolean expressions.
DeMorgan’s Law
! ( A&amp;&amp; B) = (!A) || (!B)
!(A||B) = (!A) &amp;&amp; (!B)
Notice that it is similar to the distributive postulate in mathematics. The not operator is
distributed among both terms inside of the parentheses, except the operator switches from and to
or, or vice versa.
not (A and B) = not A or not B
not (A or B) = not A and not B
In evaluating DeMorgan’s expressions the following rules need to be followed:
(1)
(2)
(3)
(4)
Change all and’s to or’s and all or’s to and’s.
Negate (!) each individual element.
Negate (!) the entire expression.
Eliminate all double Negatations (!!).
Example: !(A||B)=
1.
!(A&amp;B )
2.
!(!A &amp; !B)
3.
!!(!A &amp; !B)
4.
(!A &amp; !B)
Exercises
1.
!(A&amp;&amp; B)
2.
!((X&gt;Y) &amp;&amp; (Y &lt;= 3))
3.
(X1) &amp;&amp; (!X2) + (X1) &amp;&amp; (!X2)
4.
(2&lt; X) &amp;&amp; ( X &lt; 7)
5.
(Y&lt;0) || ( Y&gt; 12)
Solutions
1.
! (A &amp;&amp; B)
A.
B.
C.
D.
2.
!(( X &gt; Y) &amp;&amp; (Y &lt;=3))
A.
B.
C.
D.
3.
(X1 )|| (!X2) + ( X1) ||(!X3)
(!X1 )|| (!!X2) + ( !X1) ||(!!X3)
!((!X1 )|| (!!X2) + ( !X1) ||(!!X3))
!((!X1 )|| (X2) + ( !X1) ||(X3))
(2 &lt; X) &amp;&amp; (X &lt; 7)
A.
B.
C.
D.
5.
!(( X &gt; Y) || (Y &lt;=3))
!(!( X &gt; Y) || !(Y &lt;=3))
!!(!( X &gt; Y) || !(Y &lt;=3))
(( X &lt; =Y) || (Y &gt;3))
(X1 ) &amp; &amp; (!X2) + ( X1) &amp;&amp; (!X3)
A.
B.
C.
D.
4.
!(A||B)
!(!A|| !B)
!!(!A||!B)
(!A||B)
(2 &lt; X) || (X &lt; 7)
(!2 &lt; X) || (!X &lt; 7)
(!(!2 &lt; X) || (!X &lt; 7))
(!(2 &lt; = X) || (X &gt;= 7))
(Y &lt; 0)|| (Y &gt;12)
A.
B.
C.
D.
(Y &lt; 0)&amp;&amp;(Y &gt;12)
(!Y &lt; 0)&amp;&amp;(!Y &gt;12)
!((!Y &lt; 0)&amp;&amp;(!Y &gt;12))
!((Y &gt;=0)&amp;&amp;(Y &lt; =12))
References
Krane, R. R. (2000) LESSON 17: Boolean Algebra - Retrieved September 25, 2006 from the
World Wide Webshttp://dimacs.rutgers.edu/~rkrane/clecs/ict/Lesson17/cppl17.htm
Osborne, L. (2003) Fundamental of Java United States) Thomson Learning
Owen L. Astrachan (2000) Computer Science Tapestry McGraw-Hill
```