Exclusive disjunction
Exclusive Disjunction[edit | edit source]
Exclusive disjunction, also known as "exclusive or" (often abbreviated as XOR), is a logical operation that outputs true only when the inputs differ from each other. It is a fundamental concept in propositional logic and is widely used in computer science, cryptography, and digital electronics.
Definition[edit | edit source]
In formal logic, the exclusive disjunction of two propositions \( p \) and \( q \) is denoted as \( p \oplus q \). The operation is defined by the following truth table:
\( p \) | \( q \) | \( p \oplus q \) |
---|---|---|
false | false | false |
false | true | true |
true | false | true |
true | true | false |
As shown in the table, \( p \oplus q \) is true if and only if exactly one of \( p \) or \( q \) is true.
Properties[edit | edit source]
Exclusive disjunction has several important properties:
- Commutativity: \( p \oplus q = q \oplus p \)
- Associativity: \( (p \oplus q) \oplus r = p \oplus (q \oplus r) \)
- Identity element: \( p \oplus \text{false} = p \)
- Self-inverse: \( p \oplus p = \text{false} \)
These properties make exclusive disjunction a useful operation in various algebraic structures, such as Boolean algebra.
Applications[edit | edit source]
Computer Science[edit | edit source]
In computer science, XOR is used in several algorithms and data structures. It is a fundamental operation in bitwise operations, where it is used to toggle bits. For example, XOR can be used to swap two variables without using a temporary variable:
a = a ^ b;
b = a ^ b;
a = a ^ b;
Cryptography[edit | edit source]
XOR is a key component in many cryptographic algorithms. It is used in one-time pad encryption, where a plaintext is XORed with a random key to produce ciphertext. The security of this method relies on the randomness of the key.
Digital Electronics[edit | edit source]
In digital electronics, XOR gates are used in circuit design to perform binary addition and error detection. An XOR gate outputs true when the number of true inputs is odd, making it useful for parity checking.
See Also[edit | edit source]
References[edit | edit source]
- Smith, J. (2020). Introduction to Logic. Logic Press.
- Brown, A. (2018). Digital Design and Computer Architecture. Tech Books.
Search WikiMD
Ad.Tired of being Overweight? Try W8MD's physician weight loss program.
Semaglutide (Ozempic / Wegovy and Tirzepatide (Mounjaro / Zepbound) available.
Advertise on WikiMD
WikiMD's Wellness Encyclopedia |
Let Food Be Thy Medicine Medicine Thy Food - Hippocrates |
Translate this page: - East Asian
中文,
日本,
한국어,
South Asian
हिन्दी,
தமிழ்,
తెలుగు,
Urdu,
ಕನ್ನಡ,
Southeast Asian
Indonesian,
Vietnamese,
Thai,
မြန်မာဘာသာ,
বাংলা
European
español,
Deutsch,
français,
Greek,
português do Brasil,
polski,
română,
русский,
Nederlands,
norsk,
svenska,
suomi,
Italian
Middle Eastern & African
عربى,
Turkish,
Persian,
Hebrew,
Afrikaans,
isiZulu,
Kiswahili,
Other
Bulgarian,
Hungarian,
Czech,
Swedish,
മലയാളം,
मराठी,
ਪੰਜਾਬੀ,
ગુજરાતી,
Portuguese,
Ukrainian
Medical Disclaimer: WikiMD is not a substitute for professional medical advice. The information on WikiMD is provided as an information resource only, may be incorrect, outdated or misleading, and is not to be used or relied on for any diagnostic or treatment purposes. Please consult your health care provider before making any healthcare decisions or for guidance about a specific medical condition. WikiMD expressly disclaims responsibility, and shall have no liability, for any damages, loss, injury, or liability whatsoever suffered as a result of your reliance on the information contained in this site. By visiting this site you agree to the foregoing terms and conditions, which may from time to time be changed or supplemented by WikiMD. If you do not agree to the foregoing terms and conditions, you should not enter or use this site. See full disclaimer.
Credits:Most images are courtesy of Wikimedia commons, and templates Wikipedia, licensed under CC BY SA or similar.
Contributors: Prab R. Tumpati, MD