0% found this document useful (0 votes)
6 views

Logical Operators, Types Practice Example

Operation and its tyes
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Logical Operators, Types Practice Example

Operation and its tyes
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

Anees Ayoub

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

1. Negation (NOT, ¬) , (!)


yo
The NOT operator, symbolized by "¬" or simply "NOT," is the simplest logical
sA
operator. It acts on a single proposition (a statement that can be true or false) and
reverses its truth value.

Explanation:
ee

○ If a proposition P is true, then ¬P (NOT P) is false.


○ If a proposition P is false, then ¬P (NOT P) is true.
Example: Consider the proposition "It is raining." The negation of this proposition
An

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.

Importance: Negation allows us to express the opposite or contrary of a given


statement. It's a fundamental building block for constructing more complex logical
expressions.
2. Conjunction (AND, ∧), (&&)
The AND operator, often symbolized by "∧" or simply "AND," connects two
propositions and asserts that both must be true for the entire compound
statement to be 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

The OR operator, symbolized by "∨" or simply "OR" connects two propositions


and asserts that at least one of them must be true for the entire compound
statement to be true.
An

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.

Importance: XOR is used to express situations where there's a choice between


mutually exclusive options, and only one can be selected. It's often found in logic
ee

circuits and cryptography.

5. Implication (IF...THEN, →)
An

The implication operator, often represented by "→" or the words "IF...THEN,"


establishes a conditional relationship between two propositions. It asserts that if
the first proposition (the antecedent) is true, then the second proposition (the
consequent) must also be true.

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).

Importance: Implication is fundamental for expressing cause-and-effect


relationships and logical deductions. It's the basis of many mathematical and
scientific proofs.

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

Importance: The biconditional is used to define concepts, establish equivalence


between statements, and express logical relationships where two conditions are
inseparably linked.
Truth Tables:
Propositions:

● 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

True True True


An

True False False

False True False

False False False


This table demonstrates that a conjunction (AND) is only true when both of its
propositions are true.

3. Disjunction (OR, ∨)

P Q P∨Q

True True True

b
True False True

u
yo
False True True

False False False


sA
This table shows that a disjunction (OR) is true when at least one of its propositions is
true.

4. Exclusive OR (XOR, ⊕)
ee

P Q P⊕Q
An

True True False

True False True

False True True

False False False


This table illustrates that an exclusive OR (XOR) is true only when exactly one of its
propositions is true, not both.

5. Implication (IF...THEN, →)

P Q P→Q

True True True

b
True False False

u
yo
False True True

False False True


sA
This table demonstrates that an implication is only false when the antecedent (P) is true and
the consequent (Q) is false. It's true in all other cases, including when the antecedent is false.

6. Biconditional (IF AND ONLY IF, ↔)


ee

P Q P↔Q
An

True True True

True False False

False True False

False False True


This table shows that a biconditional is true only when both of its propositions have
the same truth value (either both true or both false).

Practice example 1 ( Involving multiple logical operators )

Propositions:

● P: The sun is shining.

b
● Q: It is warm outside.

Modified Sentences (Using Operators):

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

6. Biconditional: IF and ONLY IF


○ P ↔ Q: The sun is shining if and only if it is warm outside.

Answer of Practice Example 1


An

Truth Tables Rules:

● Negation (~): Reverses the truth value of a proposition.


● Conjunction (∧): True only when both propositions are true.
● Disjunction (∨): True if at least one proposition is true.
● Exclusive OR (⊕): True only when exactly one proposition is true.
● Implication (→): False only when the first proposition is true and the second is
false.
Biconditional (↔): True only when both propositions have the same truth value.
P ("The sun is shining") and Q ("It is warm outside").

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:

1. P: The sky is blue.


2. Q: It is raining.
3. R: Birds are singing.
Answer of Practice Example 2
Propositions:

1. P: The sky is blue.


2. Q: It is raining.
3. R: Birds are singing.

Modified Sentences:

b
● Negation (¬):

○ ¬P: The sky is not blue.

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 (∨):

○ P ∨ Q: The sky is blue or it is raining.


○ Q ∨ R: It is raining or birds are singing.
○ P ∨ R: The sky is blue or birds are singing.
ee

● Exclusive OR (⊕):

○ P ⊕ Q: Either the sky is blue or it is raining, but not both.


○ Q ⊕ R: Either it is raining or birds are singing, but not both.
An

○ P ⊕ R: Either the sky is blue or birds are singing, but not both.
● Implication (→):

○ P → Q: If the sky is blue, then it is raining.


○ Q → R: If it is raining, then birds are singing.
○ R → P: If birds are singing, then the sky is blue.
● Biconditional (↔):

○ P ↔ Q: The sky is blue if and only if it is raining.


○ Q ↔ R: It is raining if and only if birds are singing.
○ P ↔ R: The sky is blue if and only if birds are singing.
Truth Tables

b
u
yo
sA
ee
An

You might also like