Logical Operators, Types Practice Example
Logical Operators, Types Practice Example
Email: [email protected]
Date: 13/05/2024
Logical Operators?
What are Logical Operators?
Logical operators are symbols or words that connect two or more expressions so that
b
we can test if the entire statement is true or false. These are essential building blocks
for creating complex conditions and controlling the flow of programs.
u
Types of Logical Operators
Explanation:
ee
would be "It is not raining." If the original statement is true (it is indeed raining),
then the negation is false. If the original statement is false (it's not raining), then
the negation is true.
Explanation:
○ If both propositions P and Q are true, then P ∧ Q (P AND Q) is true.
○ If either P or Q is false (or both are false), then P ∧ Q (P AND Q) is false.
b
Example: Consider the propositions "The sky is blue" and "The grass is green." The
u
conjunction of these propositions would be "The sky is blue AND the grass is
green." This compound statement is only true if both individual propositions are
true.
yo
Importance: Conjunction is a crucial operator for expressing conditions where
sA
multiple criteria must be met simultaneously. It's commonly used in
decision-making and filtering processes.
3. Disjunction (OR, ∨)
ee
Explanation:
○ If either proposition P or Q is true (or both are true), then P ∨ Q (P OR Q) is true.
○ If both propositions P and Q are false, then P ∨ Q (P OR Q) is false.
Example: Consider the propositions "I will go to the beach" and "I will go to the
park." The disjunction of these propositions would be "I will go to the beach OR I
will go to the park." This compound statement is true if I go to either (or both) of
these locations.
Importance: Disjunction allows us to express alternatives or options where at least
one condition needs to be satisfied. It's widely used in situations where flexibility
or choice is involved.
4. Exclusive OR (XOR, ⊕)
The exclusive OR (XOR) operator, symbolized by "⊕," is similar to the OR operator
but with a key difference: it asserts that exactly one of the propositions it connects
must be true, not both.
b
Explanation:
u
○ If exactly one of the propositions P or Q is true (but not both), then P ⊕ Q (P XOR Q) is true.
○ If both propositions P and Q are true or both are false, then P ⊕ Q (P XOR Q) is false.
yo
Example: Consider the propositions "The door is open" and "The window is open."
The XOR of these propositions would be "The door is open XOR the window is
open." This compound statement is true if either the door or the window is open,
sA
but not both.
5. Implication (IF...THEN, →)
An
Explanation:
○ If P is true and Q is true, then P → Q (IF P THEN Q) is true.
○ If P is true and Q is false, then P → Q (IF P THEN Q) is false.
○ If P is false, then P → Q (IF P THEN Q) is true regardless of the truth value of Q.
Example: Consider the propositions "It is raining" (P) and "The ground is wet" (Q).
The implication P → Q would be "IF it is raining, THEN the ground is wet." This
statement is only false if it's raining (P is true), but the ground is not wet (Q is
false).
u b
6. Biconditional (IF AND ONLY IF, ↔)
The biconditional operator, symbolized by "↔" or the phrase "IF AND ONLY IF,"
yo
establishes a stronger relationship between two propositions than implication. It
asserts that the truth of one proposition is both necessary and sufficient for the
truth of the other.
sA
Explanation:
○ If both propositions P and Q are true or both are false, then P ↔ Q (P IF AND ONLY IF Q) is true.
○ If one proposition is true and the other is false, then P ↔ Q (P IF AND ONLY IF Q) is false.
Example: Consider the propositions "A triangle has three sides" (P) and "A triangle
ee
has three angles" (Q). The biconditional P ↔ Q would be "A triangle has three
sides IF AND ONLY IF it has three angles." This statement is true because having
three sides is a defining characteristic of triangles, and it inherently implies having
three angles.
An
● P: It is raining
● Q: The grass is green
1. Negation (NOT, ¬)
u b
P ¬P
True
False
False
True yo
sA
This table shows how negation reverses the truth value of a single proposition.
2. Conjunction (AND, ∧)
ee
P Q P∧Q
3. Disjunction (OR, ∨)
P Q P∨Q
b
True False True
u
yo
False True True
4. Exclusive OR (XOR, ⊕)
ee
P Q P⊕Q
An
5. Implication (IF...THEN, →)
P Q P→Q
b
True False False
u
yo
False True True
P Q P↔Q
An
Propositions:
b
● Q: It is warm outside.
u
1. Negation: NOT
yo
○ ~P: The sun is not shining.
○ ~Q: It is not warm outside.
2. Conjunction: AND
○ P ∧ Q: The sun is shining and it is warm outside.
3. Disjunction: OR
sA
○ P ∨ Q: The sun is shining or it is warm outside (or both).
4. Exclusive OR (XOR):
○ P ⊕ Q: Either the sun is shining or it is warm outside, but not both.
5. Implication: IF …. Then
○ P → Q: If the sun is shining, then it is warm outside.
ee
1. Negation (~):
P ~P
b
T F
u
F T
2. Conjunction (∧):
P Q P∧Q
yo
sA
T T T
T F F
ee
F T F
F F F
An
3. Disjunction (∨):
P Q P∨Q
T T T
T F T
F T T
F F F
4. Exclusive OR (⊕):
P Q P⊕Q
b
T T F
u
T F T
F
T
F
T
F yo
sA
5. Implication (→):
P Q P→Q
ee
T T T
T F F
An
F T T
F F T
6. Biconditional (↔):
P Q P↔Q
T T T
b
T F F
u
F T F
F F T
yo
sA
ee
Practice example 2
An
Propositions:
Modified Sentences:
b
● Negation (¬):
u
○ ¬Q: It is not raining.
○ ¬R: Birds are not singing.
● Conjunction (∧):
yo
○ P ∧ Q: The sky is blue and it is raining.
○ Q ∧ R: It is raining and birds are singing.
sA
○ P ∧ R: The sky is blue and birds are singing.
● Disjunction (∨):
● Exclusive OR (⊕):
○ P ⊕ R: Either the sky is blue or birds are singing, but not both.
● Implication (→):
b
u
yo
sA
ee
An