Boolean logic: Difference between revisions

Content deleted Content added
disputed; and move set difference to "derived binary operators"
SmackBot (talk | contribs)
m Dated {{Disputed-inline}} x 4{{Off-topic?}}. (Build p607)
Line 22:
* The '''empty set''' or '''null set''' is the set of no elements, denoted by <math>\varnothing</math> and sometimes 0.
 
* A '''unary operator''' applies to a single set. There are two{{disputedDisputed-inline|date=February 2011}} unary operators. One is called logical '''NOT'''. It works by taking the [[complement (set theory)|complement]] with respect to the universe, i.e. the set of all elements under consideration. The other is the cardinality, which converts a set into a whole number, the number of elements.{{disputedDisputed-inline|date=February 2011}} This is written as ''n(A)''.{{disputedDisputed-inline|date=February 2011}}
 
* A '''binary operator''' applies to two sets. The basic binary operators are logical '''OR''' and logical '''AND'''. They perform the [[union (set theory)|union]] and [[intersection (set theory)|intersection]] of sets. The difference between sets, ''A-B'', is the set of all elements in ''A'' and not in ''B''.{{offOff-topic?|date=February 2011}} The cartesian product, ''A×B'' is the set of ordered pairs taking one element from ''A'' and one from ''B''.{{disputedDisputed-inline|date=February 2011}}
 
There are also other derived binary operators, such as '''XOR''' (exclusive OR, i.e., "one or the other, but not both"), and set difference, '''A-B'''.
Line 134:
::(x &le; 2) ''or'' (x = 4)
 
* The plus/minus sign (<math>\pm</math>), as in the case of the solution to a square root problem, may be taken as logical OR.
 
::(Width &plusmn; 3) means
Line 145:
*In certain cases, '''AND''' and '''OR''' can be used interchangeably in English: ''I always carry an umbrella for when it rains '''and''' snows'' has the same meaning as ''I always carry an umbrella for when it rains '''or''' snows''. An alternate phrasing would be ''I always carry an umbrella for when precipitation is forecast.''
 
*The English words "and" and "or" have a meaning that usually applies more to ''sets of things'' than specific characteristics of items: "Give me all the red '''and''' blue berries" usually means, "... all the red berries '''and''' all the blue berries". Only in the context of a conversation about the characteristics of berries would the same phrase mean "... and all the berries that have both red '''and''' blue markings".
 
*Depending on the context, the word "or" may correspond with either logical '''OR''' (which corresponds to the English equivalent "and/or") or logical '''XOR''' (which corresponds to the English equivalent "either/or"):
** ''The waitress asked, "Would you like cream '''or''' sugar with your coffee?"'' This is an example of a "Logical '''OR'''", whereby the choices are cream, sugar, or cream and sugar (in addition to none of the above). This is an example of '''set''' taking precedence over '''item'''. The set of ''cream'' and ''sugar'' remains a set whether ''and'' or ''or'' are intended.
** ''The waitress asked, "Would you like soup '''or''' salad with your meal?"'' This is an example of a "Logical '''XOR'''", whereby the choices are soup or salad (or neither), but soup '''and''' salad are not an option.) This is '''item''' taking precedence over '''set'''.
** This can be a significant challenge when providing precise specifications for a computer program or electronic circuit in English. The description of such functionality may be ambiguous. Take for example the statement, "The program should verify that the applicant has checked the male '''or''' female box." This is usually interpreted as an '''XOR''' and so a verification is performed to ensure that one, and only one, box is selected. In other cases the intended interpretation of English may be less obvious; the author of the specification should be consulted to determine the original intent.
 
Line 171:
SELECT * FROM employees WHERE last_name = 'Dean' OR first_name = 'James' ;
</source>
This example will produce a list of all employees whose first name is James OR whose last name is Dean. Any and all employees named James Dean (from the first example) would also appear in this list.
 
<source lang="sql">