Course Name: Discrete Structure
Course Code: CSC-551
Credit Hours: 3(3-0)
Level: BS
Department of computer Science Government College Women University Faisalabad
UNDERSTADING OF
OR,XOR
Exclusive OR (XOR)
Composite Statements
LOGICAL EQUIVALENCE
USAGE OF “OR” IN ENGLISH
• in English language the word OR is sometimes used in an inclusive
sense (p or q or both).
• Example:
I shall buy a pen or a book.
• In the above statement, if you buy a pen or a book in both cases the
statement is true and if you buy both pen and book, then statement is
again true. Thus we say in the above statement we use or in inclusive
sense.
CONT.
• The word OR is sometimes used in an exclusive sense (p or q but not
both). As in the below statement
• Example:
Tomorrow at 9, I’ll be in Lahore or Islamabad.
• Now in above statement we are using OR in exclusive sense because
if both the statements are true, then we have F for the statement.
Exclusive OR (XOR)
• Definition
• Let p and q be propositions. The exclusive or of p and q,
denoted by p ⊕ q, is the proposition “p ⊕ q”.
• The exclusive or, p ⊕ q, is true when exactly one of p and q
is true and is false otherwise.
Examples 1
• Find the exclusive or of the propositions p and q,
Where
• p : Atif will pass the course CSC-553.
• q : Atif will fail the course CSC-553.
The exclusive or is
p ⊕ q : Atif will pass or fail the course CSC-553.
EXCLUSIVE OR:
• When OR is used in its exclusive sense, The statement “p or q” means
“p or q but not both” or “p or q and not p and q” which translates into
symbols as (p ∨ q) ∧ ~ (p ∧ q) It is abbreviated as p ⊕ q or p XOR q.
TRUTH TABLE FOR (p∨q) ∧ ~ (p ∧ q)
Note: Basically
p ⊕ q ≡ (p ∧ ∼ q) ∨ (~ p ∧ q)
≡ [p ∧ ~ q) ∨ ~ p] ∧ [(p ∧ ~ q) ∨ q]
≡ (p ∨ q) ∧ ∼ (p ∧ q)
≡ (p ∨ q) ∧ (∼ p ∨ ~ q)
Examples (OR vs XOR)
• The following proposition uses the (English) connective “or”.
Determine from the context whether “or” is intended to be used in
the inclusive or exclusive sense.
1. “Nabeel has one or two brothers”.
A person cannot have both one and two brothers. Therefore, “or” is
used in the exclusive sense.
Examples (OR vs XOR) 2.
• To register for BSc you must have passed the
qualifying exam or be listed as an Math major.
• Presumably, if you have passed the qualifying exam
and are also listed as an Math major, you can still
register for BCS. Therefore, “or” is inclusive.
Composite Statements
• Statements and operators can be combined in any way to form new
statements.
LOGICAL EQUIVALENCE
• If two logical expressions have the same logical values in the truth
table, then we say that the two logical expressions are logically
equivalent. In the following example, ~ (~ p ) is logically equivalent p.
So it is written as ~(~p) ≡ p
Example
Rewrite in a simpler form:
“It is not true that I am not happy.”
• Solution:
Let p = “I am happy”
then ~ p = “I am not happy”
and ~ ( ~ p) = “It is not true that I am not happy”
Since ~ ( ~ p) ≡ p
Hence the given statement is equivalent to “I am happy”
Example: Show that ~ (p∧q) and ~ p ∧ ~ q are not logically equivalent
• SOLUTION
• Different truth values in row 2 and row 3