You are on page 1of 10

CHAPTER VI.

CODES
A. Logic and Computer Addition

The term “logic” is often used, but not always in its technical sense. Logic is
technically defined as “the science or study of how to evaluate arguments and reasoning.”
Logic helps us to differentiate correct reasoning from poor reasoning. It is important in the
sense that it helps us to reason correctly. Others defined logic as discipline that deals with
the methods of reasoning. And logical reasoning is used on mathematics to prove theorems,
in computer science to verify correctness of programs and to prove theorems.

Mathematical logic (or symbolic logic) is a branch of mathematics with close


connections to computer science. It includes both the mathematical study of logic and the
applications of formal logic to other areas of mathematics. Mathematical logic includes the
study of the deductive formal proofs systems and expressive formal systems. Mathematical
logic has four divisions: Set Theory, Model Theory, Recursion Theory and Proof Theory.

The existence of mathematical logic has contributed to, and has been aggravated by,
the study of foundations of mathematics. The study started in the late 19th century with the
development of axiomatic frameworks for analysis, geometry and arithmetic. In our time
the work in the foundations of mathematics often centered on establishing which parts of
mathematics can be formalized, rather than trying to find theories in which all of
mathematics can be developed.

• Propositions

A proposition (or statement) is a declarative sentence which is either true or false,


but not both. The truth value of the propositions is the truth and falsity of the proposition.
Let us examine the examples below:

Example: Which of the following are propositions?

1. Manila is the capital of the Philippines.


2. What day is it?
3. Help me, please.
4. He is handsome.

Answer:

1. “Manila is the capital of the Philippines” is true, therefore it is a proposition.


2. “What day is it?” It is a question; it cannot be considered either true or false and
thus is not a proposition.
3. “Help me, please.” It cannot be categorized as true or false and therefore is not a
proposition.
4. “He is handsome.” The sentence is neither true nor false because “he” is not
specified and thus it is not a proposition.
There are also propositions (or statements) which are considered ambiguous such as

1. Mathematics is fun.
2. Calculus is more interesting than Trigonometry.
3. It was hot in Manila.
4. Street vendors are poor.
A propositional variable is a variable which is used to represent a proposition. A
formal propositional variable written using propositional logic notation, p, q, and r are
used to represent propositions. Logical connectives are used to combine simple propositions
which are referred as compound propositions. A compound proposition is a proposition
composed of two or more simple propositions connected by logical connectives “and,” ”or,”
”if then,” ”not,” ”if and only if,” and “exclusive-or.” A proposition which is not compound is
said to be simple (also called atomic).

• Logical Operators
There are six main logical connectives such as conjunction, disjunction, negation,
conditional, biconditional, and exclusive-or. The following are briefly discussed in this
section. Note that T refers to true proposition and F refers to false proposition.

a. Conjunction. The conjunction of the proposition p and q is the compound proposition “p


and q.” Symbolically, 𝑝 ∧ 𝑞, where ∧ is the symbol for "and.”

Property 1: If p is true and q is true, then , 𝑝 ∧ 𝑞 is true; otherwise , 𝑝 ∧ 𝑞 is false.


Meaning, the conjunction of two propositions is true only if each proposition is true.
P q 𝒑∧𝒒
T T T
T F F
F T F
F F F

Example: Determine the truth value of each of the following conjunction.


1. 2 + 6 = 9 and man is a mammal.
2. Manny Pacquiao is a boxing champion and Gloria Macapagal Arroyo is the first
female Philippine President.
3. Ferdinand Marcos is the only three-term Philippine President and the Philippine
Senate is composed of 24 senators.

Answer:
1. Since “2 + 6 = 9” is a false proposition (note that 2 + 6 = 9) and the proposition
"man is a mammal” is true, the conjunction of the compound proposition is
false.
P q 𝒑∧𝒒
F T F

2. In the proposition “Manny Pacquiao is a boxing champion” is true while the


proposition ”Gloria Macapagal Arroyo is the first female Philippine President” is
false (note that Corazon Aquino is the first female Philippine President),
therefore the conjunction of the compound proposition is false.
P q 𝒑∧𝒒
T F F
3. Since both the propositions ”Ferdinand Marcos is the only three-term Philippine
President” " and "Philippine Senate is composed of 24 senators” are both true,
thus the conjunction of the compound proposition is true.
P q 𝒑∧𝒒
T T T

b. Disjunction. The disjunction of the proposition p, q is the compound proposition “p or


q.” Symbolically, 𝑝 ∨ 𝑞, where ∨ is the symbol for ”or.”

Property 2: If p is true or q is true or if both p and q are true, then 𝑝 ∨ 𝑞 is true;


otherwise 𝑝 ∨ 𝑞 is false. Meaning, the disjunction of two propositions is false only if each
proposition is false.
P q 𝒑∨𝒒
T T T
T F T
F T T
F F F

Example: Determine the truth value of each of the following disjunction.


1. 2 + 6 = 9 or Manny Pacquiao is a boxing champion.
2. Philippine Senate is composed of 24 senators or Gloria Macapagal Arroyo is the
first female Philippine President.
3. Ferdinand Marcos is the only three-term Philippine President or man is a
mammal.

Answer:
1. Note that the proposition “2 + 6 = 9” is false while the proposition “Manny
Pacquiao is a boxing champion” is true; hence the disjunction of the compound
proposition is true.
p q 𝒑∨𝒒
F T T

2. Since proposition “Philippine Senate is composed of 24 senators” is true and the


proposition "Gloria Macapagal Arroyo is the first female Philippine President” is
false, therefore the disjunction of the compound proposition is true.
p q 𝒑∨𝒒
T F T

3. Given that both propositions ”Ferdinand Marcos is the only three-term Philippine
President” and “man is a mammal” are both true, thus the disjunction of the
compound proposition is true.
p q 𝒑∨𝒒
F T T

c. Negation. The negation of the proposition p is denoted by ~𝑝, where ~ is the symbol for
“not.”

Property 3: If p is true, ~p is false. Meaning, the truth value of the negation of a


proposition is always the reverse of the truth value of the original proposition.
p ~𝒑
T F
F T

Example: The following are propositions for p, find the corresponding ~𝑝.
1. 3 + 5 = 8.
2. Sofia is a girl.
3. Achaiah is not here.

Answer:
1. 3 + 5 ≠ 8.
2. Sofia is not a girl. or Sofia is a boy.
3. Achaiah is here.6

d. Conditional. The conditional (or implication) of the proposition p and q is the


compound proposition “if p then q.” Symbolically, 𝑝 → 𝑞, where → is the symbol for
“if then.” p is called hypothesis (or antecedent or premise) and q is called
conclusion (or consequent or consequence).

Property 4: The conditional proposition 𝑝 → 𝑞 is false only when p is true and q is false;
otherwise 𝑝 → 𝑞 is true. Meaning 𝑝 → 𝑞 states that a true proposition cannot imply a false
proposition.
p q 𝒑→𝒒
T T T
T F F
F T T
F F T

Example: In the proposition “If vinegar is sweet, then sugar is sour.” The antecedent is
“vinegar is sweet,” and the consequent is “sugar is sour.”
Example: Obtain the truth value of each of the following conditional propositions.
1. If vinegar is sweet, then sugar is sour.
2. 2 + 5 = 7 is a sufficient condition for 5 + 6 = 1.
3. 14 – 8 = 4 is a necessary condition that 6 ÷ 3 = 2.

Answer:
1. Since the propositions “vinegar is sweet” and the “sugar is sour” are both false,
therefore the conditional of the compound proposition is true.
p q 𝒑→𝒒
F F T

2. Note that “2 + 5 = 7” is true and “5 + 6 = 1” is false, thus the conditional of the


compound proposition is false.
P q 𝒑→𝒒
T F F

3. Given that “14 – 8 = 4” is false proposition (note that 14 – 8 = 6) while “6 ÷ 3 =


2” is a true proposition, thus the conditional of the compound proposition is
true.
P q 𝒑→𝒒
F T T

e. Biconditional. The biconditional of the proposition p and q is the compound proposition


“p if and only if q.” Symbolically, 𝑝 ⟷ 𝑞, where ⟷ is the symbol for “if and only if.”

Property 5: If p and q are true or both false, then 𝑝 ⟷ 𝑞 is true; if p and q have
opposite truth values, then 𝑝 ⟷ 𝑞 is false.
p q 𝒑⟷𝒒
T T T
T F F
F T F
F F T

Example: Determine the truth values of each of the following biconditional propositions.
1. 2 + 8 = 10 if and only if 6 – 3 = 3.
2. Manila is the capital of the Philippines is equivalent to fish live in the moon.
3. 8 – 2 = 5 is a necessary and sufficient for 4 + 2 = 7.

Answer:
1. Since the statements “2 + 8 = 10” and the “6 – 3 = 3” are both true, therefore
the conditional of the compound proposition is true.
P q 𝒑⟷𝒒
T T T

2. Note that “Manila is the capital of the Philippines” is true proposition while “fish
live in the moon” is false, thus the conditional of the compound proposition is
false.
P q 𝒑⟷𝒒
T F F

3. Given that “8 – 2 = 5” and “4 + 2 = 7” are both false, thus the conditional of


the compound proposition is true.
P q 𝒑⟷𝒒
F F T

f. Exclusive-or. The exclusive-or of the proposition p and q is the compound proposition


“p exclusive-or
q.”Symbolically, 𝑝⨁𝑞, where ⨁ is the symbol for “exclusive-or .”
Property 6: If p and q are true or both false, then 𝑝⨁𝑞 is false; if p and q have opposite
truth values, then 𝑝⨁𝑞 is true.
p q 𝑝⨁𝑞
T T F
T F T
F T T
F F F

It can be noted that the true values of 𝑝⨁𝑞 is the negation of the truth values of p ↔
q.
Given the proposition “Sofia will take her lunch in Batangas or she will have it in
Singapore,” it can be noted from the statement that “Sofia cannot have her lunch in
Batangas and at the same time do it in Singapore,” thus it is considered false.
If Sofia will have her lunch in Batangas or in Singapore, meaning she can only have
it in one location given a single schedule (the truth value is true).
Lastly, if she ought to decide to have her lunch elsewhere (neither in Batangas nor in
Singapore), therefore the truth value is false.

Common Words Associated with Various Connectives


Logical Connectives Logical Expressions Word
Conjunction 𝑝∧𝑞 p and q p but
q p also q p in
addition q p
moreover q

Disjunction 𝑝∨𝑞 p or q
Negation ∼𝑝 not p
¬𝑝 It is false that p…
𝑝′ It is not the case that p…
Conditional 𝑝⟶𝑞 If p, then q. p
implies q. p only if
q. p therefore q. p
is stronger than q.
p is sufficient
condition for q.
q if p. q follows p.
q whenever p. q is
weaker than p.
q is a necessary condition
for p.

Biconditional 𝑝⟷𝑞 p if and only if q. (p iff q) p


is equivalent to q.
p is necessary and sufficient
for q.
Exclusive-or 𝑝⨁𝑞 p exclusive-or q.
• Constructing Truth Tables
Construct the truth table for each of the following propositions.

1. ∼ 𝑝 ∨∼ 𝑞
2. 𝑝 → (𝑝 ↔ ~𝑞)
3. ~𝑝 ∧ 𝑞) ∨ (𝑝 ∧∼ 𝑞)
4. (𝑝 → 𝑞) ∨ (𝑞 ∧∼ 𝑟)
5. [(𝑝⨁𝑞) ∧ (𝑝 → 𝑞)] ∨ (𝑝 ↔ 𝑟)

Solution:

1. ∼ 𝑝 ∨∼ 𝑞
p q ∼𝒑 ∼𝒒 ∼ 𝒑 ∨∼ 𝒒
T T F F F
T F F T T
F T T F T
F F T T T

2. 𝑝 → (𝑝 ↔ ~𝑞)
p q ∼𝒒 𝒑 ↔∼ 𝒒 𝒑 → (𝒑 ↔ ~𝒒)
T T F F F
T F T T T
F T F T T
F F T F T

3. (~𝑝 ∧ 𝑞) ∨ (𝑝 ∧∼ 𝑞)
p Q ∼𝒑 ~𝒑 ∧ 𝒒 ~𝒒 (𝒑 ∧∼ 𝒒) ~𝒑 ∧ 𝒒) ∨ (𝒑 ∧∼ 𝒒)
T T F F F F F
T F F F T T T
F T T T F F T
F F T F T F F

4. (
p Q r 𝒑→𝒒 ∼𝒓 𝒒 ∧∼ 𝒓 (𝒑 → 𝒒) ∨ (𝒒 ∧∼ 𝒓)
T T T T F F T
T T F T T T T
T F T F F F F
T F F F T F F
F T T T F F T
F T F T T T T
F F T T F F T
F F F T T F T

5. [(𝑝⨁𝑞) ∧ (𝑝 → 𝑞)] ∨ (𝑝 ↔ 𝑟)
p Q r 𝑝⨁𝑞 𝑝→𝑞 (𝑝⨁𝑞) ∧ (𝑝 → 𝑞) 𝑝↔𝑟 [(𝑝⨁𝑞) ∧ (𝑝 → 𝑞)] ∨ (𝑝 ↔ 𝑟)
T T T F T F T T
T T F F T F F F
T F T T F F T T
T F F T F F F F
F T T T T T F T
F T F T T T T T
F F T F T F F F
F F F F T F T T

• Logical Equivalence and Forms of Conditional Propositions

There are three important classes of compound statements namely tautology,


contradiction, and contingency which are briefly discussed below.

1. Tautology is a compound statement that is true for all possible combinations of the
truth values of the propositional variables also called logically true.
2. Contradiction is a compound statement that is false for all possible combinations of the
truth values of the propositional variables also called logically false or absurdity.
3. Contingency is a compound statement that can be either true or false, depending on
the truth values of the propositional variables are neither a tautology nor a
contradiction.

Example: Write the truth table for each of the following compound statements and
determine whether the compound statement is tautology, contradiction or contingency.

1. (~𝑝 ∧ 𝑞) → 𝑞
2. (𝑝 → 𝑞) ∧ (𝑝 → ~𝑞)
3. (~𝑝 ∨ 𝑞) ⊕ (𝑝 → 𝑞)

Solution:

1. (~𝑝 ∧ 𝑞) → 𝑞
p q ∼𝒑 ~𝒑 ∧ 𝒒 (~𝑝 ∧ 𝑞) → 𝑞
T T F F T
T F F F T
F T T T T
F T T F T

Since all the truth values of the compound statement (~𝑝 ∧ 𝑞) → 𝑞 are true, thus it is
a tautology.

2. (𝑝 → 𝑞) ∧ (𝑝 → ~𝑞)
P q 𝑝→𝑞 ~𝑞 𝑝 → ~𝑞 (𝑝 → 𝑞) ∧ (𝑝 → ~𝑞)
T T T F F F
T F F T T F
F T T F T T
F T T T T T

Note that the truth values of the statement (𝑝 → 𝑞) ∧ (𝑝 → ~𝑞) are combinations of
true and false, therefore the compound statement is contingency.
3. (~𝑝 ∨ 𝑞) ⊕ (𝑝 → 𝑞)
P q ~𝑝 ~𝑝 ∨ 𝑞 𝑝→𝑞 (~𝑝 ∨ 𝑞) ⊕ (𝑝 → 𝑞)

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

Observe that all the truth values of the compound statement are false, thus it
is a contradiction.
Two propositions are said to be logically equivalent if they have the same
truth value for every row of the truth table, that is if 𝑥 ↔ 𝑦 is a tautology.
Symbolically, 𝑥 ≡ 𝑦.

Example: Show that the following are equivalent.

1. 𝑝 ∧ (𝑞 ∨ 𝑟) and (𝑝 ∧ 𝑞) ∨ (𝑝 ∧ 𝑟)
2. 𝑝 → 𝑞 and ~𝑞 → ~𝑝
3. 𝑝 ↔ 𝑞 and (𝑝 → 𝑞) ∧ (𝑞 → 𝑝)

Solution:

1. 𝑝 ∧ (𝑞 ∨ 𝑟) and (𝑝 ∧ 𝑞) ∨ (𝑝 ∧ 𝑞)
P q r 𝒒∨𝒓 𝒑 ∧ (𝒒 ∨ 𝒓) 𝒑∧𝒒 𝒑∧𝒓 (𝒑 ∧ 𝒒) ∨ (𝒑 ∧ 𝒓)
T T T T T T T T
T T F T T T F T
T F T T T F T T
T F F F F F F F
F T T T F F F F
F T F T F F F F
F F T T F F F F
F F F F F F F F

Observe that the truth values of compound statements 𝑝 ∧ (𝑞 ∨ 𝑟) and (𝑝 ∧ 𝑞) ∨


(𝑝 ∧ 𝑟) are the same, thus we can say that they are logically equivalent.

2. 𝑝 → 𝑞 and ~𝑞 → ~𝑝
p q 𝒑→𝒒 ~𝒒 ~𝒑 ~𝒒 → ~𝒑
T T T F T T
T F F T F F
F T T F T T
F F T T F T

Notice that the truth values of compound statements 𝑝 → 𝑞 and ~𝑞 → ~𝑝 are


equivalent; therefore we can say that they are logically equivalent.
3. 𝑝 ↔ 𝑞 and (𝑝 → 𝑞) ∧ (𝑞 → 𝑝)
p q 𝑝↔𝑞 𝑝→𝑞 𝑞→𝑝 (𝑝 → 𝑞) ∧ (𝑞 → 𝑝)
T T T T T T
T F F F T F
F T F T F F
F F T T T T

The truth values of 𝑝 ↔ 𝑞 and (𝑝 → 𝑞) ∧ (𝑞 → 𝑝) are equal, thus we can say that
they are logically equivalent.

REFERENCES:
1. Nocon, R. C., & Nocon, E. G. (2018). Essential Mathematics for the Modern World.
Quezon City: C & E Publishing, Inc.

2. Reyes, J. A. (2018). Mathematis in the Modern World. Intramuros Manila: Unlimited


Books Library Services & Publishing Inc.

3. Sirug, W. S. (2018). Mathematics in the Modern World. Intramuros, Manila:


Mindshapers Co., Inc.

You might also like