Boolean logic: Difference between revisions

Content deleted Content added
m Reverted edit(s) by 163.150.137.124 identified as test/vandalism using STiki
Line 155:
 
Care should be taken when converting an English sentence into a formal boolean statement. Many English sentences have imprecise meanings.
*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.''
 
*Sometimes the English words "and" and "or" have a meaning that is apparently opposite of its meaning in boolean logic: "Give me all the red '''and''' blue berries," usually means, "Give me all the berries that are '''either''' red '''or''' blue". (The former might have been interpreted as a request for berries that are each both red and blue.) An alternative phrasing for this request would be, "Give me all berries that are red and all berries that are blue."
In certain cases, '''AND''' and '''OR''' can be used interchangeably in English:
 
*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"):
* ''I always carry an umbrella for when it rains '''and''' snows.''
** ''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).
 
** ''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.)
* ''I always carry an umbrella for when it rains '''or''' snows.''
** 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.
 
* ''I never walk in the rain '''or''' snow.''
 
Sometimes the English words "and" and "or" have a meaning that is apparently opposite of its meaning in boolean logic:
 
* "Give me all the red '''and''' blue berries," usually means, "Give me all berries that are red '''or''' blue". (The former might have been interpreted as a request for berries that are each both red and blue.) An alternative phrasing for this request would be, "Give me all berries that are red and all berries that are blue."
 
Depending on the context, the word "or" may correspond with either logical '''OR''' or logical '''XOR''':
 
* ''The waitress asked, "Would you like cream '''or''' sugar with your coffee?"'' (Logical '''OR'''.)
 
* ''The waitress asked, "Would you like soup '''or''' salad with your meal?"'' (Logical '''XOR'''.)
 
Logical '''XOR''' can be translated as "one, or the other, but not both". In most cases, this concept is most effectively communicated in English using "[[Either|either/or]]".
 
The word combination "[[and/or]]" is sometimes used in English to specify a logical '''OR''', when just using the word "or" alone might have been mistaken as meaning logical '''XOR''':
 
* "I'm having chicken '''and/or''' beef for dinner." (Logical '''OR'''.) An alternative phrasing for standard written English would be, "For dinner, I'm having chicken or beef (or both)."
 
* The use of "and/or" is generally disfavored in [[Standard written English|formal writing]].<ref>[http://www.ntsc.navy.mil/Resources/Library/Acqguide/SpecWord.htm#and_or Usage Guide].</ref> Its usage may introduce critical imprecision in [[Legal English|legal agreements]], research findings, and [[specification]]s for [[computer program]]s or [[electronic circuit]]s.
 
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.
 
==Applications==