The Foundations: Logic and Proofs
1.2 Application of Propositional
Logic
Section Summary
Translating English sentences
Systems Specifications
Consistence System Specifications
Boolean Search
Translating English Sentences
Steps to convert an English sentence to a statement in propositional logic
Identify atomic propositions and represent using propositional variables.
Determine appropriate logical connectives
“If I go to Harry’s or to the country, I will not go shopping.”
p: I go to Harry’s
q: I go to the country.
r: I will go shopping.
If p or q then
not r.
Example
Problem: Translate the following sentence into propositional logic:
“You can access the internet from campus only if you are a computer science major or you are not a freshman”
a: “You can access the internet from campus”
b: “you are a computer science major”
c: “you are a freshman”
Where a,b,c are propositional variables
a (b c)
5
Express the specification ”The automated reply cannot be sent when the file system is full“ using logical connectives.
P: “The automated reply can be sent”
q: “The file system is full”
q p
System specifications should be consistent
They should not contain conflicting requirements that could be used to drive a contradiction
System Specifications
Consistent System Specifications
Definition: A list of propositions is consistent if it is possible to assign truth values to the
proposition variables so that each proposition is true.
Translating sentences in natural language into logical expressions is an essential part of specifying both hardware and software systems.
System and software engineers take requirements in natural language and produce precise and unambiguous specifications that can be used as the basis for system development.
7
determine whether these system specifications are consistent : a. “The diagnostic message is stored in the buffer or it is
retransmitted”
b. “The diagnostic message is not stored in the buffer”
c. “if the diagnostic message is stored in the buffer, then it is retransmitted”
P: “The diagnostic message is stored in the buffer”
q: “The diagnostic message is retransmitted”
d. p q e. p
f. pq
Consistent System Specifications
8
p q p p q
p q
p p
q p
qF F T F T
F T T T T
T F F T F
T T F T T
system specifications are consistent
Consistent System Specifications
9
determine whether these system specification are consistent : a. “The diagnostic message is stored in the buffer or it is
retransmitted”
b. “The diagnostic message is not stored in the buffer”
c. “if the diagnostic message is stored in the buffer, then it is retransmitted”
d. “The diagnostic message is not retransmitted”
P: “The diagnostic message is stored in the buffer”
q: “The diagnostic message is retransmitted”
a. p q b. p c. pq d. q
Consistent System Specifications
10
p q p p q q
p q
p p
q p
q q
F F T F T T
F T T T T F
T F F T F T
T T F T T F
system specifications are inconsistent
Consistent System Specifications
Boolean Searches
Logical connectives are used extensively in searches of large collections of information:
Indexes of Web pages, these searches employ techniques from propositional logic.
The connective
AND is used to match records that contain both of the two search items.
OR is used to match one or both of two search items.
NOT is used to exclude a particular search item (- is used in Google).