Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
150 views3 pages

Example 5:: Table 3: The Truth Table of (P Q) (P Q)

The document discusses logical operators and their precedence, constructing truth tables, and the relationship between logical operations and bit operations in computers. It defines logical operators like negation, conjunction, disjunction, implication, equivalence, and exclusive or. It also shows how logical operations correspond to bit operations like OR, AND, and XOR through their truth tables.

Uploaded by

Sheryl Bartolay
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
150 views3 pages

Example 5:: Table 3: The Truth Table of (P Q) (P Q)

The document discusses logical operators and their precedence, constructing truth tables, and the relationship between logical operations and bit operations in computers. It defines logical operators like negation, conjunction, disjunction, implication, equivalence, and exclusive or. It also shows how logical operations correspond to bit operations like OR, AND, and XOR through their truth tables.

Uploaded by

Sheryl Bartolay
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Discrete Math: Lesson 3 | ALDDedase

Lesson no. 3
Topics: • Precedence of logical operators
• Logic and bit operations
Learning objectives: 1. Construct the truth table of the compound proposition
2. Identify the bit operators OR, AND, and XOR

Lesson proper:

If you can still remember, the example below was given last week in module 2 in which we
construct a truth table for compound proposition with the help of the parentheses. We evaluate first
the negations, then each of the parentheses. To easily understand the order, the precedence of logical
operators is presented in this module.

Example 5:
Construct the truth table of the compound proposition (p ∨ ¬q) → (p ∧ q).

Solution:
Because this truth table involves two propositional variables p and q, there are four rows in
this truth table, one for each of the pairs of truth values TT, TF, FT, and FF. The first two
columns are used for the truth values of p and q, respectively. In the third column we find the
truth value of ¬q, needed to find the truth value of p ∨ ¬q, found in the fourth column. The
fifth column gives the truth value of p ∧ q. Finally, the truth value of (p ∨ ¬q) → (p ∧ q) is
found in the last column. The resulting truth table is shown in Table 3.

Table 3: The truth table of (p ∨ ¬ q) → (p ∧ q)


p q ¬q p ∨ ¬q p∧q (p ∨ ¬q) → (p ∧ q)
T T F T T T
T F T T F F
F T F F F T
F F T T F F

PRECEDENCE OF LOGICAL OPERATORS


We generally use parentheses to specify the order in which logical operators in a compound
proposition are to be applied. For instance, (p ∨ q) ∧ (¬r) is the conjunction of p ∨ q and ¬r. However,
to reduce the number of parentheses, we specify that the negation operator is applied before all other
logical operators. This means that

¬p ∧ q is the conjunction of ¬p and q, namely, (¬p) ∧ q, not the negation of the conjunction
of p and q, namely ¬(p ∧ q). (It is generally the case that unary operators that involve only
one object precede binary operators.)

Another general rule of precedence is that the conjunction operator takes precedence over
the disjunction operator, so that

p ∨ q ∧ r means p ∨ (q ∧ r) rather than (p ∨ q) ∧ r and


p ∧ q ∨ r means (p ∧ q) ∨ r rather than p ∧ (q ∨ r).

Because this rule may be difficult to remember, we will continue to use parentheses so that
the order of the disjunction and conjunction operators is clear.
Finally, it is an accepted rule that the conditional and biconditional operators, → and ↔, have
lower precedence than the conjunction and disjunction operators, ∧ and ∨. Consequently,

p → q ∨ r means p → (q ∨ r) rather than (p → q) ∨ r and


p ∨ q → r means (p ∨ q) → r rather than p ∨ (q → r).

Page 1 of 3
Discrete Math: Lesson 3 | ALDDedase

We will use parentheses when the order of the conditional operator and biconditional
operator is at issue, although the conditional operator has precedence over the biconditional
operator. Table 1 displays the precedence levels of the logical operators, ¬, ∧, ∨, →, and ↔.

Table 1: Precedence of
logical operators
Operator Precedence
¬ 1
⋀ 2
∨ 3
→ 4
↔ 5

Let us have some more examples of constructing truth tables for compound proposition.
The 2 examples presented below are the solutions of the 2 items given in your activity 2.
Examples:
Construct the truth table of the compound proposition
1. (p ⋀ q) ↔ q

Solution:
P q p∧q (p ∧ q) ↔ q
T T T T
T F F T
F T F F
F F F T

2. (p → q)⋀ (¬p ↔ q)

Solution:
p q ¬p p→q ¬𝐩 ↔ q (p → q) ⋀(¬𝐩 ↔ q)
T T F T F F
T F F F T F
F T T T T T
F F T T F F

3. (p ∨ q) → (p ⋀ q)

Solution:
p q p∨q 𝐩⋀q (p ∨ q) → (p ⋀ q)
T T T T T
T F T F F
F T T F F
F F F F T

4. (p → q) ↔ (¬q → ¬p)

Solution:
p q ¬p ¬q p→q ¬𝐪 → ¬p (p → q) ↔ (¬𝐪 → ¬𝐩)
T T F F T T T
T F F T F F T
F T T F T T T
F F T T T T T

5. (p → q) ∨ (¬p → q)

Solution:
p q ¬p p→q ¬𝐩 → 𝐪 (p → q) ↔ (¬𝐪 → ¬𝐩)
T T F T T T
T F F F T T

Page 2 of 3
Discrete Math: Lesson 3 | ALDDedase

F T T T T T
F F T T F T

A proposition that is always true is called a tautology. Examples number 4 and 5 are examples of
tautology.
A proposition that is always false is called a contradiction.
A proposition that is neither a tautology nor a contradiction is called a contingency. Examples 1, 2
and 3 are examples of contingency.

Let’s define first the exclusive OR before we go to the logic and bit operations. Exclusive OR is another
logical operator.

Note:
Definition: Exclusive or (XOR)
Let p and q be propositions. The exclusive or of p and q, denoted by p ⊕ q (or p XOR q), is the
proposition that is true when exactly one of p and q is true and is false otherwise.

Example 3.1:
Table 3.1: Truth table
Let p and q be the propositions
for Exclusive Or of two
p: “A student can have a salad with dinner”
propositions
q: “A student can have soup with dinner,”
p q p⊕q
What is p ⊕ q, the exclusive or of p and q? T T F
T F T
F T T
Solution: F F F
The exclusive or of p and q is the statement that is true when exactly one of p and q is true. That is, p
⊕ q is the statement “A student can have soup or salad, but not both, with dinner.” Note that this is
often stated as
“A student can have soup or a salad with dinner,”
without explicitly stating that taking both is not permitted.

LOGIC AND BIT OPERATIONS


Computers represent information using bits. A bit is a symbol with two possible values,
namely, 0 (zero) and 1 (one). This meaning of the word bit comes from binary digit, because zeros
and ones are the digits used in binary representations of numbers. The well-known statistician John
Tukey introduced this terminology in 1946.
A bit can be used to represent a truth value, because there are two truth values, namely, true
and false. As is customarily done, we will use a 1 bit to represent true and a 0 bit to represent false.
That is, 1 represents T (true), 0 represents F (false). A variable is called a Boolean variable if its value
is either true or false. Consequently, a Boolean variable can be represented using a bit.
Computer bit operations correspond to the logical connectives. By replacing true by a one
and false by a zero in the truth tables for the operators ∧, ∨, and ⊕, the columns in table 3 for the
corresponding bit operations are obtained. We will also use the notation OR, AND, and XOR for the
operators ∨, ∧, and ⊕, as is done in various programming languages.

The following tables show the bit operation of logical operators.

Table 2: Bit operation Table 3: Bit operators OR, AND, and XOR
for negation x y x∨y x∧y x⊕y
Truth value Bit 0 0 0 0 0
T 1 0 1 1 0 1
F 0 1 0 1 0 1
1 1 1 1 0

REFERENCE/S:

Rosen, Kenneth H. (2019). Discrete Mathematics and its application (Eight edition). Mc Graw Hill
Education. ISBN 978-1-259-67651-2

Page 3 of 3

You might also like