OR is a fundamental logical operator representing disjunction. In classical logic, a compound proposition formed by OR is true if at least one of its component propositions (disjuncts) is true. It is commonly denoted by the symbol ∨ (logical OR), the word “or” in natural language, or the vertical barin programming. OR is one of the basic operations in Boolean algebra and is essential in digital circuit design, computer science, and mathematical reasoning. This entry covers the definition, truth-functional properties, variants, and applications of OR, including its inclusive and exclusive forms, as well as its role in logic gates and programming languages.

1 History and Notation

1.1 Origins in Ancient Logic

The concept of logical disjunction can be traced to the works of Aristotle and the Stoic logicians, who distinguished between inclusive (“or both”) and exclusive (“one or the other but not both”) readings. However, no formal symbol existed in antiquity; the idea was expressed through natural language phrases.

1.2 Modern Symbolic Notation

1.2.1 Peano and Russell

The symbol ∨ for logical OR was introduced by Giuseppe Peano in the late 19th century (from the Latin *vel*, meaning “or”). Bertrand Russell and Alfred North Whitehead adopted it in *Principia Mathematica* (1910–1913), standardizing its use in formal logic.

1.2.2 Computer Science Conventions

In programming and digital logic, OR is commonly represented by the vertical bar ` (bitwise) or double vertical bar ` (logical). Boolean algebra textbooks sometimes use the plus sign (+) for OR, especially in switching theory. The inclusive variant is usually assumed unless exclusive OR (XOR) is specified.

2 Truth-Functional Definition

2.1 Truth Table for Inclusive OR

The inclusive OR of two propositions *p* and *q* is true when at least one is true. Its truth table is:

*p**q**p* ∨ *q*
TTT
TFT
FTT
FFF

2.2 Logical Properties

2.2.1 Commutativity

OR is commutative: *p* ∨ *q* is logically equivalent to *q* ∨ *p*.

2.2.2 Associativity

OR is associative: (*p* ∨ *q*) ∨ *r* is equivalent to *p* ∨ (*q* ∨ *r*), so parentheses can be omitted.

2.2.3 Idempotence

OR is idempotent: *p* ∨ *p* ≡ *p*.

2.2.4 Identity and Annihilator

The identity element for OR is false (F): *p* ∨ F ≡ *p*. The annihilator is true (T): *p* ∨ T ≡ T.

3 Variants of OR

3.1 Inclusive OR (Disjunction)

The standard OR (∨) is inclusive: it is true when at least one disjunct is true, including the case where both are true. This is the default interpretation in formal logic and most computer science contexts.

3.2 Exclusive OR (XOR)

3.2.1 Truth Table and Properties

Exclusive OR (XOR) is true only when exactly one of its operands is true. Its truth table is:

*p**q**p* ⊻ *q*
TTF
TFT
FTT
FFF

XOR is commutative, associative, and satisfies *p* ⊻ *p* ≡ F.

3.2.2 Relationship to Inclusive OR

Inclusive OR and XOR are related as: *p* ⊻ *q* ≡ (*p* ∨ *q*) ∧ ¬(*p* ∧ *q*). XOR can be seen as OR without the conjunction case.

3.3 Logical NOR (Negation of OR)

The NOR connective (↓, Pierce arrow) is the negation of OR: *p* ↓ *q* ≡ ¬(*p* ∨ *q*). It is true only when both operands are false. NOR is functionally complete—any logical operation can be expressed using only NOR gates.

4 Applications

4.1 In Computer Science

4.1.1 Bitwise OR Operation

In programming, bitwise OR (`) compares corresponding bits of two integers. A result bit is 1 if at least one of the input bits is 1. For example, 53 (binary 101011) yields 111` (7). This is used for setting flags and bitmask manipulation.

4.1.2 Logical OR in Programming Languages

Logical OR (` in C-inspired languages, or in Python, in JavaScript) evaluates to a Boolean value, typically returning true` if either operand is truthy. In some languages, it returns the first truthy operand.

4.1.3 Short-Circuit Evaluation

Most programming languages implement short-circuit evaluation for logical OR: the second operand is evaluated only if the first is false. This is used for conditional execution and to avoid errors (e.g., `if (ptr == NULL*ptr == 0)`).

4.2 In Mathematics

4.2.1 Set Union

In set theory, the union of two sets *A* ∪ *B* is the set of elements belonging to *A* or *B* (inclusive). This operation mirrors logical OR.

4.2.2 Boolean Algebra

In Boolean algebra, OR corresponds to addition modulo 2 (if restricted to exclusive OR) or the lattice join operation. It satisfies the laws of idempotence, commutativity, associativity, and absorption.

4.3 In Natural Language

4.3.1 Ambiguity between Inclusive and Exclusive OR

In everyday English, “or” can be inclusive (“You can have tea or coffee” – possibly both) or exclusive (“You can have coffee or tea, but not both”). Context often disambiguates. Logic and law frequently specify “and/or” for inclusive OR.

4.3.2 Pragmatic Uses (“or else” constructions)

Phrases like “do it or else” imply a conditional threat, where the second disjunct is an undesirable consequence. This pragmatic use goes beyond truth-functional disjunction, introducing a rhetorical or imperative force.

5.1 AND (Conjunction)

AND (∧) is true only when both operands are true. It is the dual of OR under De Morgan’s laws: ¬(*p* ∨ *q*) ≡ (¬*p*) ∧ (¬*q*). AND is also commutative, associative, and idempotent.

5.2 NOT (Negation)

NOT (¬) flips the truth value of a proposition. Combined with OR, it yields other operators (e.g., NOR, implication).

5.3 NAND and NOR

NAND (↑) is the negation of AND; NOR (↓) is the negation of OR. Both are functionally complete. NAND gates are common in digital electronics.

5.4 XOR vs. OR

XOR (exclusive OR) differs from inclusive OR only in the case where both inputs are true. XOR is essential for adders, parity checks, and cryptography. In Boolean algebra, XOR is addition modulo 2, while OR is the max operation in a Boolean lattice.

6.1 “This OR That” Choice Memes

Online, the format “This OR That?” presents two options for humorous or relatable dilemmas (e.g., “Pizza OR tacos?”). These memes play on the ambiguity of OR, often implying an exclusive choice while the comments discuss inclusive possibilities.

6.2 OR as a Comic Device in Programming Humor

Programmers joke about the dual meaning of OR. A common meme shows a character asking “Do you want A or B?” and the programmer responds with the code `if (wantAwantB)` to include both. Another running gag is the “OR operator” used to combine impossible conditions, such as “I will finish this project OR I will sleep.” The humor derives from the logical truth that if one disjunct is false, the other must be true—often an unrealistic expectation.