Exclusive or , exclusive disjunction , exclusive alternation , logical non-equivalence , or logical inequality is a logical operator whose negation is the logical biconditional . With two inputs, XOR is true if and only if the inputs differ (one is true, one is false). With multiple inputs, XOR is true if and only if the number of true inputs is odd .
48-1139: It gains the name "exclusive or" because the meaning of "or" is ambiguous when both operands are true. XOR excludes that case. Some informal ways of describing XOR are "one or the other but not both", "either one or the other", and "A or B, but not A and B". It is symbolized by the prefix operator J {\displaystyle J} and by the infix operators XOR ( / ˌ ɛ k s ˈ ɔː r / , / ˌ ɛ k s ˈ ɔː / , / ˈ k s ɔː r / or / ˈ k s ɔː / ), EOR , EXOR , ∨ ˙ {\displaystyle {\dot {\vee }}} , ∨ ¯ {\displaystyle {\overline {\vee }}} , ∨ _ {\displaystyle {\underline {\vee }}} , ⩛ , ⊕ {\displaystyle \oplus } , ↮ {\displaystyle \nleftrightarrow } , and ≢ {\displaystyle \not \equiv } . The truth table of A ⊕ B {\displaystyle A\oplus B} shows that it outputs true whenever
96-414: A i = a 1 ∧ a 2 ∧ … a n − 1 ∧ a n {\displaystyle \bigwedge _{i=1}^{n}a_{i}=a_{1}\wedge a_{2}\wedge \ldots a_{n-1}\wedge a_{n}} In classical logic , logical conjunction is an operation on two logical values , typically the values of two propositions , that produces
144-400: A literal constant, or a label. A simple example (in the x86 architecture) is where the value in register operand AX is to be moved ( MOV ) into register DS . Depending on the instruction , there may be zero, one, two, or more operands. Logical conjunction In logic , mathematics and linguistics , and ( ∧ {\displaystyle \wedge } ) is
192-423: A mathematical expression, the order of operation is carried out from left to right. Start with the leftmost value and seek the first operation to be carried out in accordance with the order specified above (i.e., start with parentheses and end with the addition/subtraction group). For example, in the expression the first operation to be acted upon is any and all expressions found inside a parenthesis. So beginning at
240-471: A random bit XORed with a non-random bit will result in a random bit. Multiple sources of potentially random data can be combined using XOR, and the unpredictability of the output is guaranteed to be at least as good as the best individual source. XOR is used in RAID 3–6 for creating parity information. For example, RAID can "back up" bytes 10011100 2 and 01101100 2 from two (or more) hard drives by XORing
288-485: A simple adder can be made with an XOR gate to add the numbers, and a series of AND, OR and NOT gates to create the carry output. On some computer architectures, it is more efficient to store a zero in a register by XOR-ing the register with itself (bits XOR-ed with themselves are always zero) than to load and store the value zero. In cryptography , XOR is sometimes used as a simple, self-inverse mixing function, such as in one-time pad or Feistel network systems. XOR
336-406: A specific terms, all the more when function composition or currying can be used to avoid them. Other terms include: In computer programming languages , the definitions of operator and operand are almost the same as in mathematics. In computing, an operand is the part of a computer instruction which specifies what data is to be manipulated or operated on, while at the same time representing
384-412: A value of true if and only if (also known as iff) both of its operands are true. The conjunctive identity is true, which is to say that AND-ing an expression with true will never change the value of the expression. In keeping with the concept of vacuous truth , when conjunction is defined as an operator or function of arbitrary arity , the empty conjunction (AND-ing over an empty set of operands)
432-557: Is a group . This unfortunately prevents the combination of these two systems into larger structures, such as a mathematical ring . However, the system using exclusive or ( { T , F } , ⊕ ) {\displaystyle (\{T,F\},\oplus )} is an abelian group . The combination of operators ∧ {\displaystyle \wedge } and ⊕ {\displaystyle \oplus } over elements { T , F } {\displaystyle \{T,F\}} produce
480-428: Is a classically valid , simple argument form . The argument form has two premises, A {\displaystyle A} and B {\displaystyle B} . Intuitively, it permits the inference of their conjunction. or in logical operator notation, where \vdash expresses provability: Here is an example of an argument that fits the form conjunction introduction : Conjunction elimination
528-542: Is also called "not left-right arrow" ( \nleftrightarrow ) in LaTeX -based markdown ( ↮ {\displaystyle \nleftrightarrow } ). Apart from the ASCII codes, the operator is encoded at U+22BB ⊻ XOR ( ⊻ ) and U+2295 ⊕ CIRCLED PLUS ( ⊕, ⊕ ), both in block mathematical operators . Operand In mathematics , an operand
SECTION 10
#1732766072794576-556: Is also found in other languages. However, many languages have disjunctive constructions which are robustly exclusive such as French soit... soit . The symbol used for exclusive disjunction varies from one field of application to the next, and even depends on the properties being emphasized in a given context of discussion. In addition to the abbreviation "XOR", any of the following symbols may also be seen: If using binary values for true (1) and false (0), then exclusive or works exactly like addition modulo 2. Exclusive disjunction
624-497: Is also heavily used in block ciphers such as AES (Rijndael) or Serpent and in block cipher implementation (CBC, CFB, OFB or CTR). In simple threshold-activated artificial neural networks , modeling the XOR function requires a second layer because XOR is not a linearly separable function. Similarly, XOR can be used in generating entropy pools for hardware random number generators . The XOR operation preserves randomness, meaning that
672-503: Is another classically valid , simple argument form . Intuitively, it permits the inference from any conjunction of either element of that conjunction. ...or alternatively, In logical operator notation: ...or alternatively, A conjunction A ∧ B {\displaystyle A\land B} is proven false by establishing either ¬ A {\displaystyle \neg A} or ¬ B {\displaystyle \neg B} . In terms of
720-475: Is called the function's algebraic normal form . Disjunction is often understood exclusively in natural languages . In English, the disjunctive word "or" is often understood exclusively, particularly when used with the particle "either". The English example below would normally be understood in conversation as implying that Mary is not both a singer and a poet. However, disjunction can also be understood inclusively, even in combination with "either". For instance,
768-511: Is commonly represented by an infix operator, usually as a keyword such as " AND ", an algebraic multiplication, or the ampersand symbol & (sometimes doubled as in && ). Many languages also provide short-circuit control structures corresponding to logical conjunction. Logical conjunction is often used for bitwise operations, where 0 corresponds to false and 1 to true: The operation can also be applied to two binary words viewed as bitstrings of equal length, by taking
816-550: Is equivalent to the disjunction of the negation of its antecedent and its consequence) and material equivalence . In summary, we have, in mathematical and in engineering notation: By applying the spirit of De Morgan's laws , we get: ¬ ( p ↮ q ) ⇔ ¬ p ↮ q ⇔ p ↮ ¬ q . {\displaystyle \lnot (p\nleftrightarrow q)\Leftrightarrow \lnot p\nleftrightarrow q\Leftrightarrow p\nleftrightarrow \lnot q.} Although
864-458: Is expressed with an exponent is 2 . We find the value of 2 , which is 4. What we have left is the expression The next order of operation is multiplication. 4 × 4 is 16. Now our expression looks like this: The next order of operation according to the rules is division. However, there is no division operator sign (÷) in the expression, 16 − 6. So we move on to the next order of operation, i.e., addition and subtraction, which have
912-440: Is often defined as having the result true. The truth table of A ∧ B {\displaystyle A\land B} : In systems where logical conjunction is not a primitive, it may be defined as It can be checked by the following truth table (compare the last two columns): or It can be checked by the following truth table (compare the last two columns): As a rule of inference, conjunction introduction
960-469: Is often used for bitwise operations. Examples: As noted above, since exclusive disjunction is identical to addition modulo 2, the bitwise exclusive disjunction of two n -bit strings is identical to the standard vector of addition in the vector space ( Z / 2 Z ) n {\displaystyle (\mathbb {Z} /2\mathbb {Z} )^{n}} . In computer science, exclusive disjunction has several uses: In logical circuits,
1008-398: Is sometimes useful to write p ↮ q {\displaystyle p\nleftrightarrow q} in the following way: or: This equivalence can be established by applying De Morgan's laws twice to the fourth line of the above proof. The exclusive or is also equivalent to the negation of a logical biconditional , by the rules of material implication (a material conditional
SECTION 20
#17327660727941056-400: Is the most modern and widely used. The and of a set of operands is true if and only if all of its operands are true, i.e., A ∧ B {\displaystyle A\land B} is true if and only if A {\displaystyle A} is true and B {\displaystyle B} is true. An operand of a conjunction is a conjunct . Beyond logic,
1104-408: Is the object of a mathematical operation , i.e., it is the object or quantity that is operated on. The following arithmetic expression shows an example of operators and operands: In the above example, '+' is the symbol for the operation called addition . The operand '3' is one of the inputs (quantities) followed by the addition operator , and the operand '6' is the other input necessary for
1152-423: The logical conjunction ("logical and", ∧ {\displaystyle \wedge } ), the disjunction ("logical or", ∨ {\displaystyle \lor } ), and the negation ( ¬ {\displaystyle \lnot } ) as follows: The exclusive disjunction p ↮ q {\displaystyle p\nleftrightarrow q} can also be expressed in
1200-426: The mathematical notation being used the position of an operator in relation to its operand(s) may vary. In everyday usage infix notation is the most common, however other notations also exist, such as the prefix and postfix notations. These alternate notations are most common within computer science . Below is a comparison of three different notations — all represent an addition of the numbers '1' and '2' In
1248-529: The operators ∧ {\displaystyle \wedge } ( conjunction ) and ∨ {\displaystyle \lor } ( disjunction ) are very useful in logic systems, they fail a more generalizable structure in the following way: The systems ( { T , F } , ∧ ) {\displaystyle (\{T,F\},\wedge )} and ( { T , F } , ∨ ) {\displaystyle (\{T,F\},\lor )} are monoids , but neither
1296-512: The truth-functional operator of conjunction or logical conjunction . The logical connective of this operator is typically represented as ∧ {\displaystyle \wedge } or & {\displaystyle \&} or K {\displaystyle K} (prefix) or × {\displaystyle \times } or ⋅ {\displaystyle \cdot } in which ∧ {\displaystyle \wedge }
1344-535: The above have motivated analyses of the exclusivity inference as pragmatic conversational implicatures calculated on the basis of an inclusive semantics . Implicatures are typically cancellable and do not arise in downward entailing contexts if their calculation depends on the Maxim of Quantity . However, some researchers have treated exclusivity as a bona fide semantic entailment and proposed nonclassical logics which would validate it. This behavior of English "or"
1392-421: The bitwise AND of each pair of bits at corresponding positions. For example: This can be used to select part of a bitstring using a bit mask . For example, 1001 1 101 AND 0000 1 000 = 0000 1 000 extracts the fourth bit of an 8-bit bitstring. In computer networking , bit masks are used to derive the network address of a subnet within an existing network from a given IP address , by ANDing
1440-673: The conjunction false: In other words, a conjunction can actually be proven false just by knowing about the relation of its conjuncts, and not necessary about their truth values. This formula can be seen as a special case of when C {\displaystyle C} is a false proposition. Either of the above are constructively valid proofs by contradiction. commutativity : yes associativity : yes distributivity : with various operations, especially with or with exclusive or : with material nonimplication : with itself: idempotency : yes monotonicity : yes truth-preserving: yes When all inputs are true,
1488-411: The data itself. A computer instruction describes an operation such as add or multiply X, while the operand (or operands, as there can be more than one) specify on which X to operate as well as the value of X. Additionally, in assembly language , an operand is a value (an argument) on which the instruction , named by mnemonic , operates. The operand may be a processor register , a memory address ,
Exclusive or - Misplaced Pages Continue
1536-405: The first example below shows that "either" can be felicitously used in combination with an outright statement that both disjuncts are true. The second example shows that the exclusive inference vanishes away under downward entailing contexts. If disjunction were understood as exclusive in this example, it would leave open the possibility that some people ate both rice and beans. Examples such as
1584-399: The following way: This representation of XOR may be found useful when constructing a circuit or network, because it has only one ¬ {\displaystyle \lnot } operation and small number of ∧ {\displaystyle \land } and ∨ {\displaystyle \lor } operations. A proof of this identity is given below: It
1632-459: The incorrect value because the order of operation was not followed. The reader will arrive at the correct value for the expression if and only if each operation is carried out in the proper order. The number of operands of an operator is called its arity . Based on arity, operators are chiefly classified as nullary (no operands), unary (1 operand), binary (2 operands), ternary (3 operands). Higher arities are less frequently denominated through
1680-596: The inputs differ: Exclusive disjunction essentially means 'either one, but not both nor none'. In other words, the statement is true if and only if one is true and the other is false. For example, if two horses are racing, then one of the two will win the race, but not both of them. The exclusive disjunction p ↮ q {\displaystyle p\nleftrightarrow q} , also denoted by p ? q {\displaystyle p\operatorname {?} q} or J p q {\displaystyle Jpq} , can be expressed in terms of
1728-405: The just mentioned bytes, resulting in ( 11110000 2 ) and writing it to another drive. Under this method, if any one of the three hard drives are lost, the lost byte can be re-created by XORing bytes from the remaining drives. For instance, if the drive containing 01101100 2 is lost, 10011100 2 and 11110000 2 can be XORed to recover the lost byte. XOR is also used to detect an overflow in
1776-402: The left and moving to the right, find the first (and in this case, the only) parenthesis, that is, (2 + 2 ). Within the parenthesis itself is found the expression 2 . The reader is required to find the value of 2 before going any further. The value of 2 is 4. Having found this value, the remaining expression looks like this: The next step is to calculate the value of expression inside
1824-404: The logical "AND" operation as multiplication on F 2 {\displaystyle \mathbb {F} _{2}} and the "XOR" operation as addition on F 2 {\displaystyle \mathbb {F} _{2}} : The description of a Boolean function as a polynomial in F 2 {\displaystyle \mathbb {F} _{2}} , using this basis,
1872-417: The object language, this reads This formula can be seen as a special case of when C {\displaystyle C} is a false proposition. If A {\displaystyle A} implies ¬ B {\displaystyle \neg B} , then both ¬ A {\displaystyle \neg A} as well as A {\displaystyle A} prove
1920-423: The operation. The result of the operation is 9. (The number '9' is also called the sum of the augend 3 and the addend 6.) An operand, then, is also referred to as "one of the inputs (quantities) for an operation". Operands may be nested, and may consist of expressions also made up of operators with operands. In the above expression '(3 + 5)' is the first operand for the multiplication operator and '2'
1968-457: The operator is K {\displaystyle K} , for Polish koniunkcja . In mathematics, the conjunction of an arbitrary number of elements a 1 , … , a n {\displaystyle a_{1},\ldots ,a_{n}} can be denoted as an iterated binary operation using a "big wedge" ⋀ (Unicode U+22C0 ⋀ N-ARY LOGICAL AND ): ⋀ i = 1 n
Exclusive or - Misplaced Pages Continue
2016-401: The output is true. falsehood-preserving: yes When all inputs are false, the output is false. Walsh spectrum : (1,-1,-1,1) Non linearity : 1 (the function is bent ) If using binary values for true (1) and false (0), then logical conjunction works exactly like normal arithmetic multiplication . In high-level computer programming and digital electronics , logical conjunction
2064-478: The parenthesis itself, that is, (2 + 4) = 6. Our expression now looks like this: Having calculated the parenthetical part of the expression, we start over again beginning with the left most value and move right. The next order of operation (according to the rules) is exponents. Start at the left most value, that is, 4, and scan your eyes to the right and search for the first exponent you come across. The first (and only) expression we come across that
2112-777: The result of a signed binary arithmetic operation. If the leftmost retained bit of the result is not the same as the infinite number of digits to the left, then that means overflow occurred. XORing those two bits will give a "1" if there is an overflow. XOR can be used to swap two numeric variables in computers, using the XOR swap algorithm ; however this is regarded as more of a curiosity and not encouraged in practice. XOR linked lists leverage XOR properties in order to save space to represent doubly linked list data structures. In computer graphics , XOR-based drawing methods are often used to manage such items as bounding boxes and cursors on systems without alpha channels or overlay planes. It
2160-422: The same precedence and are done left to right. So the correct value for our original expression, 4 × 2 − (2 + 2 ), is 10. It is important to carry out the order of operation in accordance with rules set by convention. If the reader evaluates an expression but does not follow the correct order of operation, the reader will come forth with a different value. The different value will be
2208-466: The second. The operand '(3 + 5)' is an expression in itself, which contains an addition operator, with the operands '3' and '5'. Rules of precedence affect which values form operands for which operators: In the above expression, the multiplication operator has the higher precedence than the addition operator, so the multiplication operator has operands of '5' and '2'. The addition operator has operands of '3' and '5 × 2'. Depending on
2256-613: The term "conjunction" also refers to similar concepts in other fields: And is usually denoted by an infix operator: in mathematics and logic, it is denoted by a "wedge" ∧ {\displaystyle \wedge } (Unicode U+2227 ∧ LOGICAL AND ), & {\displaystyle \&} or × {\displaystyle \times } ; in electronics, ⋅ {\displaystyle \cdot } ; and in programming languages, & , && , or and . In Jan Łukasiewicz 's prefix notation for logic ,
2304-520: The well-known two-element field F 2 {\displaystyle \mathbb {F} _{2}} . This field can represent any logic obtainable with the system ( ∧ , ∨ ) {\displaystyle (\land ,\lor )} and has the added benefit of the arsenal of algebraic analysis tools for fields. More specifically, if one associates F {\displaystyle F} with 0 and T {\displaystyle T} with 1, one can interpret
#793206