You are on page 1of 7

10/29/12

Discrete Math Review

n  What you should know about propositional


Discrete Math Review and predicate logic before the next midterm!
(Rosen, Chapter 1.1 – 1.6) n  Less theory, more problem solving, will be
repeated in recitation and homework.
TOPICS

•  Propositional Logic
•  Logical Operators
•  Truth Tables
•  Implication
•  Logical Equivalence
•  Inference Rules
10/1/12 CS160 Fall Semester 2012 2

Propositional Logic Logical Operators

n  A proposition is a statement that is either true n  ¬ logical not (negation)
or false n  ∨ logical or (disjunction)
n  Examples: n  ∧ logical and (conjunction)
Fort Collins is in Nebraska (false)
n 
n  ⊕ logical exclusive or
n  Java is case sensitive (true)
n  → logical implication (conditional)
n  We are not alone in the universe (?)
n  ↔ logical bi-implication (biconditional)
n  Every proposition is true or false, but its truth
value may be unknown

10/1/12 CS160 Fall Semester 2012 3 10/1/12 CS160 Fall Semester 2012 4

1
10/29/12

Truth Tables Compound Propositions


n  Propositions and operators can be
combined into compound propositions.
p q p∧q p q p→ q
n  (2) You should be able to make a truth table
T T T T T T
for any compound proposition:
T F F T F F
p q ¬p p→q ¬p ∧ (p→q)
F T F F T T
T T F T F
F F F F F T
T F F F F
n  (1) You should be able to write out the truth F T T T T
table for all logical operators, from memory. F F T T T
10/1/12 CS160 Fall Semester 2012 5 10/1/12 CS160 Fall Semester 2012 6

English to Propositional Logic Propositional Logic to English

n  (3) You should be able to translate natural n  (4) You should be able to translate
language to logic (can be ambiguous!): propositional logic to natural language:
n  English: n  Logic:
“If the car is out of gas, then it will stop” p equals “it is raining”
n  Logic: q equals “the grass will be wet”
p equals “the car is out of gas” p→q
q equals “the car will stop” n  English:
p→q “If it is raining, the grass will be wet.”

10/1/12 CS160 Fall Semester 2012 7 10/1/12 CS160 Fall Semester 2012 8

2
10/29/12

Logical Equivalences: Definition Logical Equivalences: Truth Tables

n  Certain propositions are equivalent (meaning n  (5) And you should know how to prove logical
they share exactly the same truth values): equivalence with a truth table
n  For example: n  For example: ¬(p ∧ q) ≡ ¬p ∨ ¬q
¬(p ∧ q) ≡ ¬p ∨ ¬q De Morgan’s p q ¬p ¬q (p ∧ q) ¬(p ∧ q) ¬p ∨ ¬q
(p ∧ T) ≡ p Identity Law T T F F T F F
(p ∧ ¬p) ≡ F Negation Law T F F T F T T
F T T F F T T
F F T T F T T
10/1/12 CS160 Fall Semester 2012 9 10/1/12 CS160 Fall Semester 2012 10

Logical Equivalences: Review Logical Equivalences (Rosen)


n  (6) You should understand the logical
equivalences and laws on the course web site.
n  You should be able to prove any of them using
a truth table that compares the truth values of
both sides of the equivalence.
n  Memorization of the logical equivalences is not
required in this class.

10/1/12 CS160 Fall Semester 2012 11 10/1/12 CS160 Fall Semester 2012 12

3
10/29/12

Transformation via Logical


Equivalences Vocabulary
(7) You should be able to transform propositions
n  (8) You should memorize the following
using logical equivalences.
vocabulary:
n  A tautology is a compound proposition that is
Prove: ¬p ∨ (p ∧ q) ≡ ¬(p ∧ ¬q)
always true.
¬p ∨ (p ∧ q) ≡ (¬p ∨ p) ∧ (¬p ∨ q) n  Distributive law n  A contradiction is a compound proposition

≡  T ∧ (¬p ∨ q) n  Negation law that is always false.


≡  (¬p ∨ q) n  Domination law n  A contingency is neither a tautology nor a

≡  ¬(p ∧ ¬q) n  De Morgan’s Law contradiction.


n  And know how to decide the category for a
compound proposition.
10/1/12 CS160 Fall Semester 2012 13 10/1/12 CS160 Fall Semester 2012 14

Examples Logical Proof


n  Given a set of axioms
p ¬p p ∨¬p p ∧¬p
n  Statements asserted to be true

T F T F n  Prove a conclusion


n  Another propositional statement
F T T F
Result is always
n  In other words:
false, no matter
n  Show that the conclusion is true …
what A is
Result is always
n  … whenever the axioms are true
true, no matter
what A is Therefore, it is a Therefore, it is a
tautology contradiction

10/1/12 CS160 Fall Semester 2012 15 10/1/12 CS160 Fall Semester 2012 16

4
10/29/12

Logical Proof Method 1: Proof by Truth Table


n  (9) You should be able to perform a logical n  Prove that p → q, given ¬ p
proof via truth tables.
For all rows in
n  (10) You should be able to perform a logical p q ¬p p→q which axiom is
proof via inference rules. true, conclusion
T T F T is true
T F F F
n  Both methods are described in the following
slides. F T T T Thus the
conclusion
F F T T
follows from
axiom
10/1/12 CS160 Fall Semester 2012 17 10/1/12 CS160 Fall Semester 2012 18

Method 2: Proof using Rules of


Inference Applying rules of inference
n  A rule of inference is a proven relation: when n  Example rule: p, p→q ∴ q
the left hand side (LHS) is true, the right
hand side (RHS) is also true. n  Read as “p and p→q, therefore q”
n  Therefore, if we can match an axiom to the n  This rule has a name: modus ponens
LHS by substituting propositions, we can n  If you have axioms r, r→s
assert the (substituted) RHS
n  Substitute r for p, s for q
n  Apply modus ponens
n  Conclude s

10/1/12 CS160 Fall Semester 2012 19 10/1/12 CS160 Fall Semester 2012 20

5
10/29/12

Modus Ponens Modus Tollens


n If p, and p implies q, then q n If not q and p implies q, then not p
Example: Example:
p = it is sunny, q = it is hot p = it is sunny, q = it is hot
p → q, it is hot whenever it is sunny p → q, it is hot whenever it is sunny
“Given the above, if it is sunny, it must “Given the above, if it is not hot, it
be hot”. cannot be sunny.”

10/1/12 CS160 Fall Semester 2012 21 10/1/12 CS160 Fall Semester 2012 22

Rules of Inference (Rosen) A Simple Proof: Problem Statement

Example of a complete proof using inference rules,


from English to propositional logic and back:
n  If you don’t go to the store, then you cannot not
cook dinner. (axiom)
n  If you cannot cook dinner or go out, you will be
hungry tonight. (axiom)
n  You are not hungry tonight, and you didn’t go to
the store. (axiom)
n  You must have gone out to dinner. (conclusion)
10/1/12 CS160 Fall Semester 2012 23 10/1/12 CS160 Fall Semester 2012 24

6
10/29/12

A Simple Proof: Logic Translation A Simple Proof: Applying Inference

n  p: you go to the store ¬p → ¬q, ¬(q ∨ r) → s, ¬s, ¬p



n  q: you can cook dinner

n  r: you will go out ¬p, ¬p → ¬q ∴ ¬q modus ponens
n  s: you will be hungry ¬s, ¬(q ∨ r) → s ∴ q ∨ r
modus tollens
n  AXIOMS: ¬p → ¬q, ¬(q ∨ r) → s, ¬s, ¬p
¬q, q ∨ r ∴ r disjunctive syllogism
n  CONCLUSION: r
CONCLUSION: r
You must have gone out to dinner!
10/1/12 CS160 Fall Semester 2012 25 10/1/12 CS160 Fall Semester 2012 26

Predicate Logic Predicate Logic (cont’d)

n  (11) You should recognize predicate logic n  Specifies a proposition (and optionally a
symbols, i.e. quantifications. domain), for example:
n  Quantification express the extent to which a n  ∃x ∈ N, -10 < x < -5 // False, since no negative x
predicate is true over a set of elements: n  ∀x ∈ N, x > -1 // True, since no negative x
n  Universal ∀, “for all” n  Predicate logic has similar equivalences and
n  Existential ∃, “there exists” inference rules (De Morgan’s):
n  (12) You should able to translate between n  ∀x: P(x) = ¬∃x : ¬P(x) // True for all = false for none
predicate logic and English, in both directions. n  ¬∀x: P(x) = ∃x : ¬P(x) // Not true for all = false for some

10/1/12 CS160 Fall Semester 2012 27 10/1/12 CS160 Fall Semester 2012 28

You might also like