De Morgan's Law

user3003605 picture user3003605 · Nov 18, 2013 · Viewed 12.8k times · Source

I am trying to simplify the following using DeMorgan's Law: ! (x!=0 || y !=0)

Does x!=0 simplify to x>0? Or am I wrong in the following:

 !(x>0 || y>0)
 !(x>0) && !(y>0)
 ((x<=0) && (y<=0))

Thanks.

Answer

Alexis C. picture Alexis C. · Nov 18, 2013

Does x!=0 simplify to x>0?

No that's not true. Because integers are signed.


How to simplify : !(x!=0 || y !=0) ?

Consider this rules :

  1. enter image description here (second De Morgan's laws )

  2. enter image description here

By 1., it implies

!(x!=0 || y !=0) <=> (!(x!=0)) && (!(y != 0))

By 2., it implies

(!(x!=0)) && (!(y != 0)) <=> (x == 0) && (y == 0)


To test you can write the following loop :

for(int x = -5; x < 5; x++){
     for(int y = -5; y < 5; y++){
         if(!(x!=0 || y !=0))
            System.out.println("True : ("+x+","+y+")");
    }
}