You are on page 1of 59

Propositional Logic and

Logic Circuits
Application of Logic in IT and CS

● Used in the design of computer circuits


● Construction of Computer programs
● Verification of correctness of programs

Discrete Structures 101 2


Propositions

- Basic building blocks of logic


- A declarative sentence that is either TRUE or
FALSE but not both

Discrete Structures 101 3


Tell whether the following is a proposition or not.
1. Washington, D.C., is the capital of the United States of
America.
2. Please lend me your ears!
3. Manila is the capital of Philippines.
4. 2 + 5 = 7
5. 12 < 7
6. 10 - 3 = 7
7. Today is wednesday
Discrete Structures 101 4
Your
Turn
Determine whether proposition
or not
1. Ouch! 6. Please close the door
2. All multiples of 5 are 7. Is it hot outside?
odd numbers. 8. X+1=2 when x=1
3. x is a real number. 9. The earth is round.
4. Sketch the graph of 𝑓. 10.I am yours.
5. 2+5=5
Propositional Variables / statement variables

- Variables that represent propositions


- Letters are often used to denote propositional variables
- Conventional letters used for propositional variables are
p, q, r, s
- The truth value of a proposition is denoted by either T if
the proposition is True and F if the proposition is False

Discrete Structures 101 6


Compound Propositions

- A combination of two or more propositions


- These propositions are using logical
operators (conjunction, disjunction,
conditional statements, biconditional
statements, negation)

Discrete Structures 101 7


Example:

Find the negation of the proposition “ Michael’s PC runs Linux”.

Discrete Structures 101 8


9
Find the negation of the following propositions:

1. Vandana’s smartphone has at least 32GB of


memory
2. Alex birthday is on March 27, 1991
3. It is raining today.
4. The mall is closed today.
5. Maria owns 2 iPhones.
10
Example:

Find p ^ q where

p = Rebecca’s PC has more than 16 Gb free


hard disk space, and
q = The processor in Rebecca’s PC runs
faster than 1 GHz
11
Example:

Find p v q where

p = Rebecca’s PC has more than 16 Gb


free hard disk space, and
q = The processor in Rebecca’s PC runs
faster than 1 GHz

12
13
Variety of ways to express conditional
statements:
“p implies q”
“p only if q”
“if p, then q”
“a sufficient condition for q is p”
“if p, q”
“q whenever p”
“p is sufficient for q”
“q is necessary for p”
“q if p”
“q follows from p”
“q when p”
“a necessary condition for p is q”
“q unless ¬p” 14
15
Converse, Contrapositive, and Inverse
CONVERSE of INVERSE of

CONTRAPOSITIVE of

16
p->q : If the triangle is isosceles, then
the base angles are congruent.
• Converse:
• If the base angles are congruent, then the triangle is
isosceles.

• Inverse:
• If the triangle is not isosceles, then the base angles
are not congruent.

• Contrapositive:
• If the base angles are not congruent, then the triangle is
not isosceles.
What are the contrapositive, the converse, and the inverse of the conditional statement?

“The home team wins whenever it is raining.”

Q whenever P is the same as p -> q, therefore, it can


be written as “If it is raining, then the home team wins” 18
Other ways to express p ↔q:

“p is necessary and sufficient for q”


“if p then q, and conversely”
“p iff q”

19
20
Truth Table
What is a truth table?
Compound Propositions

Example:
Construct the truth table of the compound proposition:

26
27
Another Solution

T T F T T T T T

T T T F F T F F

F F F T T F F T

F T T F F F F F
28
29
30
31
32
33
Assignment: (Due Next Week)

34
35
Precedence of Logical Operators

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.

36
Logic and Bit Operations

Bit (binary digit) is a symbol with


two possible values - 0 and 1.
- 0 for false and 1 for true
Boolean variable - a variable
whose value is either true or
false
37
38
Example:

1 0 1 0 1 0 0 1 1 is a bit string of length nine.

1 1 0 0 1 1 0 1 is a bit string of length eight.

39
40
Examples: (C and D Seatwork)

41
Logic Circuits
Logic circuit (digital circuit)
● Propositional logic can be applied to the design of computer hardware.
This was first observed in 1938 by Claude Shannon in his MIT master’s
thesis.

It is an electronic circuit having one or more inputs and only one


output. The relationship between the input and output is based
on a certain logic. Hence logic gates are named as AND gate, OR
gate, NOT gate.
A logic circuit (or digital circuit) receives input signals p1, p2,...,pn, each a
bit [either 0 (off) or 1 (on)], and produces output signals s1, s2,...,sn, each a
bit. 43
FIGURE 1. Basic
Logic Gates

44
Inverter (Not Gate)

Input Output

0 1

1 0

45
OR Gate Input
1
1 Output
0
0 1
1
1
1
0
0
1
0 46
AND Gate Input
1
1 Output
0
0 1
0
0
1
0
0
1
0 47
Combinatorial Circuit

● A combinatorial circuit is a generalized gate. In


general such a circuit has m inputs and n outputs.

48
Find the output of this
combinatorial circuit

49
Solution:

50
51
- (p ˄ (q ˅ -r))

q ˅ -r p ˄ (q ˅ -r)
-r

52
-p
-p˄-q
(- p ˄ - q)˅ (p ˄ r)
-q

p˄r

53
Your Turn

54
Answers:
-p
-p˅-q
-q

p v (- p ˄ q)
-p

-(p ˄ (- p ˄ q))
-p˄q
55
Exercise 1 (Show on the board)
Build a digital circuit that produces the
output (p ∨ ¬r) ∧ (¬p ∨ (q ∨ ¬r)) when
given input bits p, q, and r.

56
Solution to Exercise 1
(p ∨ ¬r) ∧ (¬p ∨ (q ∨ ¬r))

57
-p
-p ˅ -r
(-p ˅ -r) ˄ -q
-r
-q
-p

-p ˄ (q ˅ r)
q˅r
58
Your Turn

59

You might also like