Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

De Morgan's Law

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.

like image 476
user3003605 Avatar asked Nov 18 '13 08:11

user3003605


People also ask

What are De Morgan's Law explain?

De Morgan's First Law states that the complement of the union of two sets is the intersection of their complements. Whereas De Morgan's second law states that the complement of the intersection of two sets is the union of their complements. These two laws are called De Morgan's Law.

What are the two De Morgan's Law?

DeMorgan's first theorem states that two (or more) variables NOR´ed together is the same as the two variables inverted (Complement) and AND´ed, while the second theorem states that two (or more) variables NAND´ed together is the same as the two terms inverted (Complement) and OR´ed.

What is De Morgan's Law prove it?

De Morgan's Law states that how mathematical statements and concepts are related through their opposites. In set theory, De Morgan's Laws describe the complement of the union of two sets is always equals to the intersection of their complements.


2 Answers

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+")");
    }
}
like image 162
Alexis C. Avatar answered Sep 26 '22 02:09

Alexis C.


DeMorgans Law states the following:

!(A & B) = !A | !B    (I)
!(A | B) = !A & !B    (II)

In your case (II) applies: !(x!=0 || y!=0) => !(x!=0) && !(y!=0) => (x==0) && (y==0)

PS: Your question: "Does x!=0 simplify to x>0?" can be answered with "no" unless x can not take negative values (for example if the type of x is unsigned).

like image 22
brimborium Avatar answered Sep 23 '22 02:09

brimborium