You are on page 1of 11

8/16/20

Elementary Logic and


Bits Operations
(Mathematical Logic)

No student is allowed to upload any portion(s) of AdDU Math in the Modern World PDFs to PDF or slide sharing sites.

Language
• a systematic means of communicating by the use of
sounds or conventional symbols (Chen, 2010)

1
8/16/20

Mathematics as a Language
It is a universal language, the only one shared by all human beings
regardless of culture, religion, or gender.

Not everyone can be proficient in English, French, Chinese or


Japanese but most possess math literacy.

Mathematical Language Elements


Symbols for number: 0, 1, 2, …
Symbols for operation: +, -, x, …
Symbols for values: x, y, z, …
Other special symbols: <, >, π, …

Start of the alphabet a, b, c for constants (fixed values)

From i to n i, j, k, n positive integers (for counting)

End of the alphabet x, y, z For variables (unknown)

2
8/16/20

Mathematical Language Elements


Constants
Noun
12, - 58
Operations
Verb
=, >, <
Variables
Pronouns
5x – 8, x, y
Mathematical Sentences
Sentences
3x + 7 = 24, 2x + 3y = 7

Propositional Calculus
A proposition is a complete declarative sentence that use either true or
false, but not both.

If a proposition p is true, its truth value is true, denoted by T. If its is


false, its truth value is false, denoted by F.

3
8/16/20

Propositional Calculus
Examples:
• Manila is the capital of the Philippines.
• Shanghai is the capital of China.
• 1+1=2
• 2+2=3
Non-examples:
• Is it time?
• Pay attention to this.
• x+1=2
• x+y=z

Connectives and Compound


Propositions
A propositional connective is an operation that combines
two propositions to yield a new one whose truth value
depends only on the truth values of the two original
propositions. Propositions built up by combining
propositions using propositional connectives are called
compound propositions.

4
8/16/20

Propositional Connectives (A Review)


Let p be a proposition and q be another proposition.

Exclusive Disjunction
Conjunction Disjunction
(exclusive or/
p q (and) (or)
either but not both)
p˄q p˅q
p⨁q
T T T T F
T F F T T
F T F T T
F F F F F

p: Today is Friday.; q: It is raining today.

Conjunction: Today is Friday and it is raining today.


Disjunction: Today is Friday or it is raining today.
Exclusive Disjunction: Either today is Friday or it is raining, but not both.

Propositional Connectives (A Review)


Let p be a proposition and q be another proposition.

Conditional/Implication Biconditional
p q (If – then/ implies) (if and only if)
pàq p↔q
T T T T
T F F F
F T T F
F F T T

p: Today is Friday.; q: It is raining today.

Conditional: If today is Friday, then it is raining today.


Biconditional: Today is Friday if and only if it is raining today,

10

5
8/16/20

Negation
Negation is unary. Let p be a proposition. The “negation” of p is
written as ~p. Observe that p and ~p cannot both have the same
truth value.

TRUTH TABLE FOR NEGATION

p ~p
T F
F T

Example : Let p : Today is Friday.


~p : Today is not Friday.

11

Conditionals
In 𝑝 → 𝑞, the proposition p is the hypothesis or antecedent and
the proposition q is the conclusion or consequence.
Types of conditional statements:
(a) Conditional (𝑝 → 𝑞)
If today is Friday, then it is raining today.

(b) Converse (𝑞 → 𝑝)
If it is raining today, then today is Friday.

(c) Inverse (~𝑝 → ~𝑞)


If today is not Friday, then it is not raining today.

(d) Contrapositive (~𝑞 → ~𝑝)


If it is not raining today, then today is not Friday.

12

6
8/16/20

Compound Proposition
A compound proposition that is always true, regardless of the truth
values of the proposition that occur in it, is called a tautology. A
contradiction is a compound proposition that is always false. While a
contingency is neither a tautology nor a contradiction.

For each of the following compound propositions, determine if it a


tautology, contradiction or contingency.
(a) 𝑝 ∨ 𝑞 ∧ ~𝑝 ∧ ~𝑞
(b) (~ 𝑝 ↔ 𝑞 → 𝑟) ∨ (𝑝 ∧ ~𝑟)

13

Logical Equivalence
The propositions p and q are logically equivalent if 𝑝 ↔ 𝑞 is a tautology.
It is denoted by the notion 𝑝 ⟺ 𝑞. An implication is always logically
equivalent to its own contrapositive.

Logical
Name Logical Equivalence Name
Equivalence
𝑝∧𝑻⟺𝑝 𝑝∨𝑞 ⟺𝑞∨𝑝 Commutative
Identity laws
𝑝∨𝑭⟺𝑝 𝑝∧𝑞 ⟺𝑞∧𝑝 laws
𝑝∨𝑻⟺𝑻 Domination (𝑝 ∨ 𝑞) ∨ 𝑟 ⟺ 𝑝 ∨ (𝑞 ∨ 𝑟) Associative
𝑝∧𝑭⟺𝑭 Laws (𝑝 ∧ 𝑞) ∧ 𝑟 ⟺ 𝑝 ∧ (𝑞 ∧ 𝑟) laws
𝑝∨𝑝⟺𝑝 Idempotent 𝑝 ∧ (𝑞 ∨ 𝑟) ⟺ (𝑝 ∧ 𝑞) ∨ (𝑝 ∧ 𝑟) Distributive
𝑝∧𝑝⟺𝑝 laws 𝑝 ∨ (𝑞 ∧ 𝑟) ⟺ (𝑝 ∨ 𝑞) ∧ (𝑝 ∨ 𝑟) laws
Double ~ 𝑝 ∧ 𝑞 ⟺ ~𝑝 ∨ ~𝑞 De Morgan’s
~(~𝑝) ⟺ 𝑝
negation law ~ 𝑝 ∨ 𝑞 ⟺ ~𝑝 ∧ ~𝑞 laws

14

7
8/16/20

Bit Operations
Bit is short for binary digit. Computers represent information using bits.
A bit has two possible values, 0 and 1, which represent a truth value.
As customary done, 1 will be used to represent T and 0 will be used to
represent F.

A bit string is a sequence of zero or more bits. The length of this string
is the number of bits in the string. Hence, 101001100 is a bit string of
length 9.

A byte is 8 bits.
A word is 16 bits or 2 bytes.

15

Bit Operations
What is the decimal value of the binary 10110001?

1 → 1 x 2! = 1 x 128 = 128
0 → 0 x 2" = 0 x 64 = 0
1 → 1 x 2# = 1 x 32 = 32
1 → 1 x 2$ = 1 x 16 = 16
0 → 0 x 2% =0x 8= 0
0 → 0 x 2& =0x 4= 0
0 → 0 x 2' =0x 2= 0
1 → 1 x 2( =1x 1= 1

16

8
8/16/20

Some Logic Gates


The bitwise OR, bitwise AND, and bitwise XOR of two strings of the
same length are defined as the strings that have as their bits the
connectives OR, AND, and XOR of the corresponding bits in the two
strings respectively.

OR 0 1 AND 0 1 XOR 0 1
0 0 1 0 0 0 0 0 1
1 1 1 1 0 1 1 1 0

Consider the two bit strings 0110110110 and 1100011101. Find


(a) bitwise OR
(b) bitwise AND
(c) bitwise XOR

17

TRY THESE!!!
I. Construct the truth table for the following compound
propositions. After which, tell if the proposition is a
tautology, contradiction or contingency.
1. 𝑝∨𝑞 → 𝑝∧𝑞
2. [(𝑝 ∨ 𝑞) ∧ 𝑟] → [(𝑝 ∧ 𝑟) ∨ 𝑞]
II. Tell if 𝑝 → 𝑞 → 𝑟 ⇔ 𝑝 → (𝑞 → 𝑟) is correct.
III. Find the bitwise OR, bitwise AND, and bitwise XOR of
each pair of bit strings.
1. 1011110, 0100001
2. 11110000, 10101010

18

9
8/16/20

ANSWER KEY
I. Construct the truth table for the following compound
propositions. After which, tell if the proposition is a
tautology, contradiction or contingency.
1. 𝑝∨𝑞 → 𝑝∧𝑞

2n = 22 = 4 rows or combinations

𝒑 𝒒 𝒑∨𝒒 𝒑∧𝒒 𝑝∨𝑞 → 𝑝∧𝑞


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

Contingency

19

ANSWER KEY
2. [(𝑝 ∨ 𝑞) ∧ 𝑟] → [(𝑝 ∧ 𝑟) ∨ 𝑞]

2n = 23 = 8 rows or combinations

𝑝 𝑞 𝑟 𝑝 ∨ 𝑞 (𝑝 ∨ 𝑞) ∧ 𝑟 𝑝 ∧ 𝑟 (𝑝 ∧ 𝑟) ∨ 𝑞 [(𝑝 ∨ 𝑞) ∧ 𝑟] → [(𝑝 ∧ 𝑟) ∨ 𝑞]
T T T T T T T T
T T F T F F T T
T F T T T T T T
T F F T F F F T
F T T T T F T T
F T F T F F T T
F F T F F F F T
F F F F F F F T

Tautology

20

10
8/16/20

ANSWER KEY
II. Tell if 𝑝 → 𝑞 → 𝑟 ⇔ 𝑝 → (𝑞 → 𝑟) is correct.
2n = 23 = 8 rows or combinations

𝑝 𝑞 𝑟 𝑝→𝑞 (𝑝 → 𝑞) → 𝑟 𝒒→𝑟 𝑝 → (𝒒 → 𝒓) 𝑝 → 𝑞 → 𝑟 ⇔ 𝑝 → (𝑞 → 𝑟)
T T T T T T T T
T T F T F F F T
T F T F T T T T
T F F F T T T T
F T T T T T T T
F T F T F F T F
F F T T T T T T
F F F T F T T F

Incorrect

21

ANSWER KEY
III. Find the bitwise OR, bitwise AND, and bitwise XOR of
each pair of bit strings.

Bitwise OR Bitwise AND Bitwise XOR


1011110, 0100001 1111111 0000000 1111111
11110000, 10101010 11111010 10100000 01011010

22

11

You might also like