CHAPTER 1: Propositional Logic
CHAPTER 1: Propositional Logic
1.Introduction
The rules of logic give precise meaning to mathematical statements. These rules are used
to distinguish between valid and invalid mathematical arguments. Because a major goal
of this CORSE is to teach the reader how to understand and how to construct correct
mathematical arguments, we begin our study of discrete mathematics with an
introduction to logic. Besides the importance of logic in understanding mathematical
reasoning, logic has numerous applications to computer science. These rules are used in
the design of computer circuits, the construction of computer programs, the veri?cation of
the correctness of programs, and in many other ways. Furthermore, software systems
have been developed for constructing some, but not all, types of proofs automatically.
We will discuss these applications of logic in this and later chapters.
1.Propositions
Our discussion begins with an introduction to the basic building blocks of
logic propositions. A proposition is a declarative sentence (that is, a sentence
that declares a fact) that is either true or false, but not both.
EXAMPLE 1 All the following declarative sentences are propositions.
1. Washington, D.C., is the capital of the United States of America.
2. Toronto is the capital of Canada.
3. 1+1 = 2.
4. 2+2 = 3.
Propositions 1 and 3 are true, whereas 2 and 4 are false.
Some sentences that are not propositions are given in in following Example
Exercise
Find the negation of the proposition
Vandana's smartphone has at least 32GB of memory
and express this in simple English.
this is done, operations on the bit strings can be used to manipulate this
information.
DEFINITION 7
A bit string is a sequence of zero or more bits. The length of this string is the
number of bitsbin the string.
EXAMPLE
101010011 is a bit string of length nine.
▲
Exercice
Find the bitwise OR, bitwise AND, and bitwise XOR of the bit strings
01 1011 0110 and 11 0001 1101. (Here, and throughout this book, bit strings
will be split into blocks of four bits to make them easier to read.)
Solution: The bitwise OR, bitwise AND, and bitwise XOR of these strings
are obtained by taking the OR, AND, and XOR of the corresponding bits,
respectively. This gives us
01 1011 0110
11 0001 1101
--------------------------
11 1011 1111 OR
01 0001 0100 AND
10 1010 1011 XOR
EXERCICE 1
EXAMPLE 1
How can this English sentence be translated into a logical expression?
“You can access the Internet from campus only if you are a computer
science major or you are not a freshman.”
Solution: There are many ways to translate this sentence into a logical
expression. Although it is possible to represent the sentence by a single
propositional variable, such as p, this would not be useful when analyzing its
meaning or reasoning with it. Instead, we will use propositional variables to
represent each sentence part and determine the appropriate logical
connectives between them.
In particular, we let a, c, and f represent “You can access the Internet from
campus,”
“You are a computer science major,” and “You are a freshman,” respectively.
Noting that “only if” is one way a conditional statement can be expressed,
this sentence can be represented as
a → (c V ¬f ).
▲
exercise : replace only if by if
exercise : replace only if by if and only if
EXAMPLE 2
How can this English sentence be translated into a logical expression?
“You cannot ride the roller coaster if you are under 4 feet tall unless you are
older than 16
years old.”
Solution: Let q, r, and s represent “You can ride the roller coaster,” “You are
under 4 feet tall,”
and “You are older than 16 years old,” respectively. Then the sentence can
be translated to
(r V ¬s) → ¬q.
Of course, there are other ways to represent the original sentence as a logical
expression,
but the one we have used should meet our needs.
▲
Logic Circuits
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. we will study this
topic
in depth. We give a brief introduction to this application here.
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. In
this section we will
restrict our attention to logic circuits with a single output signal; in general,
digital circuits may
have multiple outputs.
If p=1 , q=1 and r=0 then result of the logice circuit behind is 1
------------------------------------------------------------------------------------------
EXAMPLE 10
Build a digital circuit that produces the output (p V ¬r) ^ (¬p V (q V¬r))
when given input bits p, q, and r.
1.3
Propositional Equivalences
1.4 Predicates and Quantifiers
1,
Let Q(x, y) denote the statement “x = y + 3.” What are the truth values of the
propositions Q(1, 2) and Q(3, 0)?
2,
Similarly, we can let R(x, y, z) denote the statement `‘x + y = z.” When
values are assigned
to the variables x, y, and z, this statement has a truth value.
What are the truth values of the propositions R(1, 2, 3) and R(0, 0, 1)?
3,
Consider the statement
if x > 0 then x := x + 1.
When this statement is encountered in a program, the value of the variable x
at that point in the
execution of the program is inserted into P (x), which is “x > 0.” If P (x) is
true for this value
of x, the assignment statement x := x + 1 is executed, so the value of x is
increased by 1. If
P (x) is false for this value of x, the assignment statement is not executed, so
the value of x is
not changed.
▲
▲
Consider these statements. The first two are called premises and the third is
called the conclusion.
The entire set is called an argument.
“All lions are fierce.”
“Some lions do not drink coffee.”
“Some fierce creatures do not drink coffee.”
Consider a Prolog program given facts telling it the instructor of each class
and in which classes students are enrolled. The program uses these facts to
answer queries concerning the professors who teach particular students.
Such a program could use the predicates instructor(p, c) and enrolled(s, c) to
represent that professor p is the instructor of course c and that student s is
enrolled in course c, respectively. For example, the Prolog facts in such a
program might include:
instructor(chan,math273)
instructor(patel,ee222)
instructor(grossman,cs301)
enrolled(kevin,math273)
enrolled(juana,ee222)
enrolled(juana,cs301)
enrolled(kiko,math273)
enrolled(kiko,cs301)
(Lowercase letters have been used for entries because Prolog considers
names beginning with an uppercase letter to be variables.)
A new predicate teaches(p, s), representing that professor p teaches student
s, can be
defined using the Prolog rule
teaches(P,S) :- instructor(P,C) , enrolled(S,C)
which means that teaches(p, s) is true if there exists a class c such that
professor p is the instructor of class c and student s is enrolled in class c.
(Note that a comma is used to represent
a conjunction of predicates in Prolog. Similarly, a semicolon is used to
represent a disjunction of predicates.)
Prolog answers queries using the facts and rules it is given. For example,
using the factsand rules listed, the query
?enrolled(kevin,math273)
produces the response
yes
because the fact enrolled(kevin, math273) was provided as input. The query
?enrolled(X,math273)
produces the response
kevin
kiko
To produce this response, Prolog determines all possible values of X for
which
enrolled(X, math273) has been included as a Prolog fact. Similarly, to find
all the professors
who are instructors in classes being taken by Juana, we use the query
?teaches(X,juana)
This query returns
patel
grossman
▲