Introduction Updated
Introduction Updated
Reasoning
Logic
• We intuitively know that Truth and Falsehood
are opposites, that statements describe the
world and can be true/false, that the world is
made up of objects and that objects can be
organized to form collections.
• It is the study of the logical relationships
between objects and forms the basis of all
mathematical reasoning and all automated
reasoning
False, True, Statements
Axiom: False is the opposite to Truth.
A statement is a description of something.
Examples of statements:
I’m 31 years old.
I have 3 children.
I always tell the truth.
I’m lying to you.
Q’s: Which statements are True? False? Both?
Neither?
False, True, Statements
True: I’m 31 years old.
False: I have 3 children.
I always tell the truth.
Both: IMPOSSIBLE, by our Axiom.
False, True, Statements
Neither: I’m lying to you. (If viewed on its own)
HUH? Well suppose that
S = “I’m lying to you.”
were true. In particular, I am actually lying, so
S is false. So it’s both true and false,
impossible by the Axiom.
Okay, so I guess S must be false. But then I
must not be lying to you. So the statement is
true. Again it’s both true and false.
In both cases we get the opposite of our
assumption, so S is neither true nor false.
Propositions
To avoid painful head-aches, we ban such
silly non-sense and avoid the most
general type of statements limiting
ourselves to statements with valid
truth-values instead:
DEF: A proposition is a statement that is
true or false, but not both.
We usually denote a proposition by a
letter: p, q, r, s, …
Propositions
Propositional Logic is a static discipline of
statements which lack semantic content.
E.G. p = “Clinton was the president.”
q = “The list of U.S. presidents includes
Clinton.”
r = “Lions like to sleep.”
All p and q are no more closely related than q
and r are, in propositional calculus. They are
both equally related as all three statements
are true. Semantically, however, p and q are
the same!
Propositions
So why waste time on such matters?
Propositional logic is the study of how simple
propositions can come together to make
more complicated propositions. If the simple
propositions were endowed with some
meaning –and they will be very soon– then
the complicated proposition would have
meaning as well, and then finding out the
truth value is actually important!
The value of a proposition is called its truth
value(True/False)
Propositions: Examples
The following are propositions
Today is Monday M
The grass is wet W
It is raining R
The following are not propositions
C++ is the best language Opinion
When is the pretest? Interrogative
Do your homework Imperative
Compound Propositions
In Propositional Logic, we assume a
collection of atomic propositions are
given: p, q, r, s, t, ….
Then we form compound propositions by
using logical connectives (logical
operators) to form propositional
“molecules”.
Logical Connectives
Operator Symbol Usage Java
Negation not !
Conjunction and &&
Disjunction or ||
Exclusive or xor (p||q)&&(!p||!q)
p p
F T
T F
Conjunction
Conjunction is a binary operator in that it
operates on two propositions when
creating compound proposition. On the
other hand, negation is a unary
operator (the only non-trivial one
possible).
Conjunction
Conjunction is supposed to encapsulate
what happens when we use the word
“and” in English. I.e., for “p and q ” to
be true, it must be the case that BOTH
p is true, as well as q. If one of these
is false, than the compound statement
is false as well.
Conjunction
EG. p = “Clinton was the president.”
q = “Monica was the president.”
r = “The meaning of is is important.”
Assuming p and r are true, while q false.
Out of pq, pr, qr
only pr is true.
Java: x==3 && x!=3
Evaluates to false for any possible value of x.
Conjunction – truth table
p q pq
T T T
T F F
F T F
F F F
Disjunction – truth table
Conversely, disjunction is true when at
least one of the components is true:
p q p q
T T T
T F T
F T T
F F F
Disjunction – caveat
Note: English version of disjunction “or”
does not always satisfy the assumption
that one of p/q being true implies that
“p or q ” is true.
Q: Can someone come up with an
example?
Disjunction – caveat
A: The entrée is served with
soup or salad.
Most restaurants definitely don’t allow
you to get both soup and salad so that
the statement is false when both soup
and salad is served. To address this
situation, exclusive-or is introduced
next.
Exclusive-Or – truth table
p q p q
T T F
T F T
F T T
F F F
p
Two compound propositions are equivalent if
they always have the same truth value
The contrapositive is equivalent to the original
statement
The converse is equivalent to the inverse
Precedence of Logical
Operators
Negation operator is applied before all
other logical operators
Conjunction operator takes precedence
over disjunction operator
Conditional and biconditional operators
have lower precedence
Parentheses are used whenever
necessary
Truth Tables
Truth tables are used to show/define the
relationships between the truth values of
the individual propositions and
the compound propositions based on them
0 0 0 0 0 1 1
0 1 0 1 1 1 0
1 0 0 1 1 0 0
1 1 1 1 0 1 1
Constructing Truth Tables
Construct the truth table for the
following compound proposition
(( p q ) q )
p q pq q (( p q ) q )
0 0 0 1 1
0 1 0 0 0
1 0 0 1 1
1 1 1 0 1
Bit Strings
Electronic computers achieve their calculations
inside semiconducting materials. For
reliability, only two stable voltage states are
used and so the most fundamental operations
are carried out by switching voltages between
these two stable states.
In logic, only two truth values are allowed.
Thus propositional logic is ideal for modeling
computers. High voltage values are modeled
by True, which for brevity we call the number
1, while low voltage values are modeled by
False or 0.
Bit Strings
Thus voltage memory stored in a computer can
be represented by a sequence of 0’s and 1’s
such as
01 1011 0010 1001
Another portion of the memory might look like
10 0010 1111 1001
Each of the number in the sequence is called a
bit, and the whole sequence of bits is called
a bit string.
Bit Strings
It turns out that the analogs of the logical
operations can be carried out quite easily
inside the computer, one bit at a time. This
can then be transferred to whole bit strings.
For example, the exclusive-or of the previous
bit strings is:
01 1011 0010 1001
10 0010 1111 1001
11 1001 1101 0000
Terminology: Tautology,
Contradictions, Contingencies
Definitions
A compound proposition that is always true,
no matter what the truth values of the
propositions that occur in it is called a
tautology
A compound proposition that is always false is
called a contradiction
A proposition that is neither a tautology nor a
contradiction is a contingency
Examples
A simple tautology is p p
A simple contradiction is p p
Logical Equivalences:
Definition
Definition: Propositions p and q are
logically equivalent if p q is a
tautology.
Informally, p and q are equivalent if
whenever p is true, q is true, and vice
versa
Notation: p q (p is equivalent to q), p
q, and p q
Alert: is not a logical connective
Logical Equivalences: Example 1
Are the propositions (p q) and (p q)
logically equivalent?
To find out, we construct the truth tables for
each: p q pq p pq
0 0
0 1
1 0
1 1
The two columns in the truth table are identical, thus we conclude that
(p q) (p q)
TABLE 7 (1.2)
TABLE 8 (1.2)
Constructing New Logical Equivalence
Ex:
“If you have a current password, then you
can log onto the network”
“You have a current password”
Therefore, “You can log onto the network”
p q
p
q
Definition 1: argument: a sequence of
propositions
Premises
Conclusion: the final proposition
Argument form: a sequence of compound
propositions involving propositional
variables
Rules of Inference fro Propositional Logic
Rules of inference
Modus ponens (law of detachment)
(p (p q)) q
TABLE 1 (1.5)
Example:
“It it not sunny this afternoon and it is
colder than yesterday”
“We will go swimming only if it is sunny”
“If we do not go swimming, then we will
take a canoe trip”
“If we take a canoe trip, then we will be
home by sunset”
Conclusion: “We will be home by sunset”
Show that the premises “If you send
me an e-mail message, then I will finish
writing the program,” “If you do not
send me an e-mail message, then I will
go to sleep early,” and “If I go to sleep
early, then I will wake up feeling
refreshed” lead to the conclusion “If I
do not finish writing the program, then
I will wake up feeling refreshed.”
Fallacies
((p q) q) p is not a tautology
Fallacy of affirming the conclusion
Example:
“If you do every problem in this book, then you
will learn discrete mathematics. You learned
discrete mathematics.
Therefore, you did every problem in this book.”
((p q) p) q is not a tautology
Fallacy of denying the hypothesis
Example: It is possible that you learned discrete
mathematics even if you did not do every problem in
this book.
Rules of Inference for Quantified
Statements
Universal instantiation
x P(x), P(c)
Universal generalization
P(c) for any c, x P(x)
Existential instantiation
x P(x), P(c) for some element c
Existential generalization
P(c) for some element c, x P(x)
TABLE 2 (1.5)
Show that the premises “Everyone in
this discrete mathematics class has
taken a course in computer science”
and “Marla is a student in this class”
imply the conclusion “Marla has taken a
course in computer science.”
Show that the premises “A student in
this class has not read the book,” and
“Everyone in this class passed the first
exam” imply the conclusion “Someone
who passed the first exam has not read
the book.”
Combining rules of inference for
propositions and quantified statements
Universal modus ponens
x (P(x) Q(x))
P(a), where a is a particular element in the
domain
Q(a)
Universal modus tollens
x (P(x) Q(x))
Q(a), where a is a particular element in the
domain
Introduction to Proofs
Some terminology
Theorem: a statement that can be shown to be
true
Axioms: statements assumed to be true
A proof is a valid argument that establishes the truth of a
theorem
Including axioms, premises of the theorem, and previously
proven theorems
Lemma: less important theorems that is helpful in
the proof
Corollary: a theorem that can be directly
established from a theorem that has been proved
Conjecture: a statement that is being proposed to
be true
Direct Proofs
pq
Assume that p is true
Showing that q must also be true
Definition 1: The integer n is even if
there exists an integer k such that
n=2k, and n is odd if there exists an
integer k such that n=2k+1.
Ex.1: Prove that “if n is an odd integer,
then n2 is odd.”
Proof by Contraposition
pq
q p
Take q as a hypothesis
Then show that p must follow
Ex.3: prove that if n is an integer and 3n+2 is
odd, then n is odd.
Vacuous proof
If we can show that p is false, then we have a
vacuous proof of p q is true
Trivial proof
If we know that the conclusion q is true, p q
must also be true
A little proof strategy
First, evaluate whether a direct proof
looks promising
Otherwise, try the same thing with a
proof by contraposition
Definition 2: The real number r is
rational is there exist integers p and q
with q0 such that r=p/q. A real
number that is not rational is called
irrational.
Ex.7: Prove that the sum of two rational
numbers is rational.
Ex.8: Prove that if n is an integer and n2
is odd, then n is odd.
Proof by Contradiction
If we can show that p (r r) is
true for some proposition r, we can
prove that p is true
Ex.9: show that at least four of any 22
days must fall on the same day of the
week.
Ex.10: prove that 2 is irrational.
Proof of equivalence
To prove that p q , we show that p q
and q p are both true
Counterexamples
To show that x P(x) is false, we need only
find a counterexample
Mistakes in proofs
Fallacy of begging the question
Circular reasoning
Proof Methods and Strategy
Proof by cases
((p1 p2 … pn) q) (p1 q) (p2
q) … (pn q)
Exhaustive proof
A special type of proof by cases that
exhaust all possibilities (if there are
relatively small number of examples)
Without loss of generality (WLOG)
By proving one case of a theorem, no
additional argument is required to prove
other specified cases
Existence Proofs
x P(x)
Constructive: find an element a such that
P(a) is true
Nonconstructive
E.g.: proof by contradiction
Uniqueness Proofs
Existence: we show that an element x
with the desired property exists
Uniqueness: we show that if yx, then y
does not have the desired property
Proof strategies
Forward and backward reasoning
Adapting existing proofs
Looking for counterexamples