Propositional Logic: Discrete Structures & Algorithms
Propositional Logic: Discrete Structures & Algorithms
Propositional Logic: Discrete Structures & Algorithms
Propositional Logic
1
Summary so far
• Pancake sorting
• A problem with many applications
• Bracketing (bounding a function)
• Proving bounds for pancake sorting
• You can make money solving such problems (Bill Gates!)
• Illustrated many concepts that we will learn in this course
• Proofs
• Sets
• Counting
• Performance of algorithms
2
Propositional logic
• Database queries
3
A sandwich is better than God
4
What is propositional logic?
Examples
p: It is raining. ¬p: It is not raining.
p: 3+2=5. ¬p: 3+2≠5.
• Disjunction (“or”): p V q
• To ride the bus you must have a ticket or hold a pass.
9
Truth tables
•Truth tables can be used to evaluate statements. A
simple proposition can either be “true” or “false”.
10
Logical equivalence
11
Implication
• q: I study.
12
Truth table for implication
• p → q: If p, then q.
• If p is true, q must be true for the implication to hold.
• p is the assumption/premise/antecedent.
• q is the conclusion/consequent.
Implication
p q p→q
T F F
T T T
F F T
F T T
13
An equivalent for implication
Is there an expression that is equivalent to p → q but uses
only the operators ¬, Λ, V?
Implication
p q p→q
F F T
Consider the F T T
proposition ¬p V q T F F
T T T
p q ¬p ¬p V q
F F T T
F T T T
T F F F
T T F T
14
Proving other equivalences
• Do this as an exercise.
15
Logical equivalences
• The basic laws Propositions that are logically equivalent. You
• Identity
will need to know them, although we will not
elaborate on them in lecture.
• Domination
In the text (Rosen): Chapter 1, Section 2.
• Idempotence
• Commutation
• Association
• Distribution
• Absorption
• De Morgan’s laws
16
Variations on a proposition
• Contrapositive: ¬q → ¬p
• Example: If a function is differentiable, then it is continuous.
18
Bi-conditionals (“if and only if”)
• If p and q are two propositions, then p ↔ q is a bi-
conditional proposition.
• p if and only if q. (p iff q)
Structure of an argument
Statement 1 (p1)
premises
Statement 2 (p2)
or
...
antecedents
Statement n (pn)
• Premises
• “If you have a current password, you can log onto the
computer network.”
• Conclusion
• “Therefore, you can log onto the computer network.”
21
Representing an argument
An argument is sometimes written as follows:
premises
conclusion
22
Valid arguments
23
Why use rules of inference?
• Constructing a truth table is time consuming!
• If we have n propositions, what is the size of the truth
table? 2n, which means that the table doubles in size
with every proposition.
Implication
p→q
p q
Two propositions are involved in an implication,
F F theT truth table has 22 = 4 rows.
therefore
F T T
T F F
T T T
24
Rules of inference
modus ponens
“method of affirming”
25
Rules of inference
modus tollens
“method of denying”
26
Rules of inference
generalization specialization
27
Rules of Inference
More rules of inference listed in the text. Try
proving them as an exercise.
Chapter 1, Section 5 (Rosen).
28
Inference Rules for Quantifiers
More rules of inference listed in the text. Try
proving them as an exercise.
Chapter 1, Section 5 (Rosen).
• x P(x)
P(o) (substitute any specific object o)
• x P(x)
P(c) (substitute a new constant c)
30
Formal Proof Example
31
Proof Example cont.
32
Proof Example cont.
• Step Proved by
1. sunny cold Premise #1.
2. sunny Simplification of 1.
3. swimsunny Premise #2.
4. swim Modus tollens on 2,3.
5. swimcanoe Premise #3.
6. canoe Modus ponens on 4,5.
7. canoeearly Premise #4.
8. early Modus ponens on 6,7.
33
Proofs and theorems
A theorem is a statement that can be shown to be
true. A proof is the means of doing so.
Axioms,
postulates,
hypotheses and
previously proven
theorems Rules of inference
Proof
34
Common Fallacies
• A fallacy is an inference rule or other proof
method that is not logically valid.
• A fallacy may yield a false conclusion!
• Example:
• If you do every problem in the book, then you will learn
mathematics. You learned mathematics.
• Example
• If you do every problem in the book, then you
will learn mathematics. You did not do every
problem in the book.
• Therefore you did not learn mathematics
(incorrect!).
36
Common fallacies:
Circular Reasoning
• The fallacy of (explicitly or implicitly) assuming the
very statement you are trying to prove in the course
of its proof. Example:
• Prove that an integer n is even, if n 2
is even.
38
Proof Methods for Implications
39
Direct Proof Example
• Definition: An integer n is called odd iff n=2k+1 for
some integer k; n is even iff n=2k for some k.
41
Vacuous Proof Example
42
Trivial Proof Example
43
Proof by Contradiction
46
Proving Existence
47
Constructive Existence Proof
48
Nonconstructive Existence Proof
• Theorem:
“There are infinitely many prime numbers.”
• Any finite set of numbers must contain a maximal
element, so we can prove the theorem if we can just
show that there is no largest prime number.
• I.e., show that for any prime number, there is a larger
number that is also prime.
• More generally: For any number, a larger prime.
• Formally: Show n p>n : p is prime.
49
The proof, using proof by cases...
50
Pancake numbers
• n P 2n – 3
n
51
Wrap up
•Propositional logic
• Or propositional calculus
• Truth tables
• Logical equivalence
• Basic laws
•Rules of inference
• Arguments
• Premises and conclusions
•Proofs
52
53