SOURCE FILE: DeMorgan.eg



First Example:

      if (the score is not in range)

	// this "does not work"
	// It means something to the C++ compiler, but
	// it is not what you want it to mean
      if (!(0<=score<=800))

	// You say it this way to get what you want
	// This is correct, but complicated-looking
      if ( ! ( (0<=score) && (score<=800) ) ) 

	// We simplify by first using one of de Morgan's laws.
	// ! ( A && B) is the same as (!A) || (!B)
      if ( ! (0<=score) || ! (score<=800)  ) 

	// We finish simplifying by using the law of
	// trichothomy of numbers: If we have two
	// numbers x and y, either x > y, x = y, or x < y.
      if ( (0 > score) ||  (score > 800)  ) 
      

Second Example:

      if ( !( (dry || hot) && (dry || ventilated) ) )
         PlaceInDryer() ;

          // Using property 3a on page 195 
      if ( !(  dry || (hot && ventilated)  ) )
         PlaceInDryer() ;

          // Using De Morgan's law a, on page 196
      if ( !dry &&  !(hot && ventilated) )
         PlaceInDryer() ;

           // Using De Morgan's law
	   // (if it is wet,  and also cool or stuffy,
	   //  then we had better put the
           //  item in the dryer.)
      if ( !dry &&  (!hot || !ventilated) )
         PlaceInDryer() ;