Definition

Boolean

What is Boolean?

In computing, the term Boolean means a result that can only have one of two possible values: true or false. Boolean logic takes two statements or expressions and applies a logical operator to generate a Boolean value that can be either true or false. To return the result, operators like AND, OR, NOT, etc. are used.

Boolean search uses Boolean logic to connect keywords or phrases in a query. A user may use this query to find specific information in a database or during a web search. The Boolean search query combines the search terms into a machine-readable format.

Boolean logic vs. fuzzy logic
Whereas fuzzy logic is an approach to computing based on 'degrees of truth,' modern computing is based on Boolean logic, which is based on the usual 'true or false' (1 or 0) dichotomy.

Boolean logic refers to a system of logical thought developed by George Boole (1815-1864) in 1854. He was an English mathematician and philosopher as well as one of the pioneers of mathematical logic that set the stage for modern computing. His goal was to combine certain concepts and exclude certain other concepts when searching databases for information.

However, it was only in 1951 that the logic system was commercialized. This happened when Bell Labs used Boolean logic as a part of AN/FSQ-7, a massive computer used by the U.S. Air Force.

Boolean logic drives modern digital devices, such as computers and smartphones. It is used to describe electromagnetically-charged memory locations or circuit states in a computer that are either charged (1 or true) or not charged (0 or false). The computer can use logic gates and Boolean operators to obtain a result that can be used for further processing.

Common Boolean operators and web searches

Boolean logic is based on several operators known as logical operators or simply Boolean operators. These operators work on a Boolean expression or conditional statement consisting of two words or other values. The Boolean operation then generates a Boolean value that expresses a "truth value."

Boolean operators are used in computer programming, mathematical formulas and algorithms. They are often used to refine web searches. Using a Boolean operator as a conjunction between two keywords in a web search either combines or excludes them, thus generating more focused and useful results.

The three most used Boolean operators are the following:

  • AND.
    • AND's purpose is to narrow the search.
    • The AND operator considers both terms in the logical operation or search which means that both terms should appear in each item returned by the search. If one term is in the searched material but the other is not, the item will not be included in the result.
    • Example: If a user searches for "pear AND apple," the system will assume that the user is looking for results containing both words and not just one of them.
  • OR.
    • OR's purpose is to broaden the search.
    • The OR operator considers either term in the operation or search. If either term is contained in the material that is being searched, it will be included in the search results.
    • Example: If the search term is "pear OR apple," the system will search for and display results that contain either pear or apple.
  • NOT or AND NOT.
    • NOT and AND NOT's purposes are to exclude specific terms from the search.
    • This operator will result in the first term being searched. Any records containing the term after the operator will not appear in the results.
    • Example: A search for "Guatemala NOT Guatemala City" will include results only for Guatemala and will not return items containing Guatemala City.
types of algorithms
Computer programming, mathematical formulas and algorithms use Boolean operators.

Other Boolean operators

In addition to AND, OR and NOT, several other Boolean operators are also frequently used:

  • NOR. NOR finds a result whose value is true only if both terms are false.
  • NAND. NAND generates a false result if both inputs are true. Otherwise, the output is true.
  • XOR. XOR acts as a logical either/or, so the output is true if either -- but not both -- of the inputs is true.

Boolean data type

The term Boolean is sometimes presented with a lower case "b": boolean. Strictly speaking, Boolean with an uppercase "B" refers to Boolean logic or Boolean algebra, while boolean refers to a data type in computer programming. The other two major data types are text and numbers.

Boolean algebra is a subset of mathematics concerned with operations on logical values, including binary variables. It underpins logical processing and decision-making in programming.

The Boolean data type values may be the following:

  • True or false
  • Yes or no
  • On or off value
  • 1 or 0

These values create conditions and determine how a program behaves in response to a certain event (e.g., if "X condition" is true, then do "Y").

Example 1: If a user types the correct password, then allow them to log in.

If a user types the correct password, the Boolean data type would be "true." It indicates that the object is valid or "true," which would allow the user to log in.

Example 2: If a user does not click on CAPTCHA, then display an error message.

If the user forgets to click on the CAPTCHA after typing in their email address and password, the object would be invalid. So the Boolean value would be "false."

captcha examples
The Boolean value would be 'false' if a user forgets to click on a CAPTCHA after typing in their email address and password, as the object would be invalid.

Boolean logic in programming

In many programming languages, Boolean operators are used with conditional statements. For example, in Perl, they can be used with if statements:

if (($name eq "Gale") && ($password eq "iloveyou")) {

 print "Success\n";

}

else {

 print "Fail\n";

 die;

}

Here, the && (AND) operator will look for username "Gale" and password "iloveyou." If both values are correct, it will print "Success." If either value is incorrect, it will print "Fail."

Similarly, in JavaScript, Boolean conditionals are used in if statements and for loops.

if (boolean conditional) {

 console.log("boolean conditional resolved to true");

} else {

 console.log("boolean conditional resolved to false");

See also: fuzzy logic, proximity operator, search string, logical negation symbol, character, Karnaugh map, Claude Shannon, truth table, logical implication and mathematical symbols

This was last updated in November 2022

Continue Reading About Boolean