Translating English Sentences: Discrete Structures CMSC 2123 1.2 Applications of Propositional Logic
Translating English Sentences: Discrete Structures CMSC 2123 1.2 Applications of Propositional Logic
“You can access the Internet from campus only if you are a computer
science major or you are not a freshman.”
“You cannot ride the roller coaster if you are under 4 feet tall unless you
are older than 16 years old.”
System Specification
Translating sentences in natural language (such as English) into logical expressions is an essential
part of specifying both hardware and software systems.
EXAMPLE 3 Express the specification “The automated reply cannot be sent when the file
system is full” using logical connectives.
1
Discrete Structures Lecture 2
CMSC 2123 1.2 Applications of Propositional Logic
Logic Circuits
Propositional logic can be applied to the design of computer hardware.
A logic circuit (or digital circuit) receives input signals 𝑝𝑝1 , 𝑝𝑝2 , ⋯ , 𝑝𝑝𝑛𝑛 , each a bit [either 0 (off) or 1
(on)], and produces output signals 𝑠𝑠, 𝑠𝑠2 , ⋯ , 𝑠𝑠𝑚𝑚 , each a bit.
p p
p ¬p p ∨q p∧ q
q q
Inverter OR gate AND gate
FIGURE 1 Basic logic gates
Complicated digital circuits can be constructed from three basic circuits, called gates, shown in
Figure 1. The inverter, or NOT gate, takes an input bit 𝑝𝑝, and produces an output ¬𝑝𝑝. The OR
gate takes two input signals 𝑝𝑝 and 𝑞𝑞, each a bit, and produces an as output the signal 𝑝𝑝 ∨ 𝑞𝑞.
Finally, the AND gate takes two input signals 𝑝𝑝 and 𝑞𝑞, each a bit, and produces an as output the
signal 𝑝𝑝 ∧ 𝑞𝑞.
p p∧¬q
q
¬q
(p∧¬q )∨¬r
r
¬r
FIGURE 2 A combinatorial circuit
2
Discrete Structures Lecture 2
CMSC 2123 1.2 Applications of Propositional Logic
EXAMPLE 10 Build a digital circuit that produces the output (𝑝𝑝 ∨ ¬𝑟𝑟) ∧ (¬𝑝𝑝 ∨ (𝑞𝑞 ∨ ¬𝑟𝑟))
Solution: Construct as shown in the steps below.
Step 1 (p ∨¬r) (p∨¬ r)∧(¬p ∨(q∨¬ r))
Step 3
p
r
¬r (p ∨¬r) (p∨¬r) ∧(¬p∨ (q∨¬ r))
Step 4
p
r
¬r (p ∨¬r) (p∨¬ r)∧(¬p ∨(q∨¬ r))
q (q∨¬r)
r
¬r
3
Discrete Structures Lecture 2
CMSC 2123 1.2 Applications of Propositional Logic
REMARK A bit is the contraction of binary digit, a zero (0) or a one (1).
DEFINITION 7 A bit string is a sequence of zero or more bits. The length of the string is the
number of bits in the string.
EXAMPLE 13 Find the bitwise OR, bitwise AND, and bitwise XOR, of the bit strings 01
1011 0110 and 11 0001 1101.
Solution:
0 1 1 0 1 1 0 1 1 0
1 1 0 0 0 1 1 1 0 1
OR 1 1 1 0 1 1 1 1 1 1
0 1 1 0 1 1 0 1 1 0
1 1 0 0 0 1 1 1 0 1
AND 0 1 0 0 0 1 0 1 0 0
0 1 1 0 1 1 0 1 1 0
1 1 0 0 0 1 1 1 0 1
XOR 1 0 1 0 1 0 1 0 1 1