Vous êtes sur la page 1sur 35

CSI2101

DISCRETE STRUCTURES

WonSook Lee
wslee@uottawa.ca
EECS, Univ. of Ottawa
The lecture note is collaborative work, and
large contribution is from Prof. Nejib Zaguia
1/10/18 1
Propositional logic
• (§1.1-1.2-1.3)
• Review from Mat 1348

2
Propositional logic: Review

Mathematical Logic is a tool for working with


elaborate compound statements. It
includes:
• A formal language for expressing them.
• A concise notation for writing them.
• A methodology for objectively reasoning
about their truth or falsity.
• It is the foundation for expressing formal
proofs in all branches of mathematics.
3
Topic #1 – Propositional Logic

Propositional logic: Review

Definition: A proposition (denoted p, q, r, …) is simply:


• a statement (i.e., a declarative sentence)
– with some definite meaning, (not vague nor ambiguous)
• having a truth value that’s either true (T) or false (F)
– it is never both, neither, or somewhere “in between!”
• However, you might not know the actual truth value,
• and, the truth value might depend on the situation
or context.

4
Topic #1 – Propositional Logic

Proposition?

• “It is raining.”
• “Who’s there?”
• “Beijing is the capital of China.”
• “La la la la la.”
• “Just do it!”
• “1 + 2 = 3”
• “1 + 2”
• “Yeah, I sorta dunno, whatever...”

5
Topic #1 – Propositional Logic

Propositional logic: Review

• “It is raining.” (In a given situation.)


• “Beijing is the capital of China.”
• “1 + 2 = 3”

But, the following are NOT propositions:


• “Who’s there?” (interrogative, question)
• “La la la la la.” (meaningless interjection)
• “Just do it!” (imperative, command)
• “Yeah, I sorta dunno, whatever...” (vague)
• “1 + 2” (expression with a non-true/false value)

6
Topic #1.0 – Propositional Logic: Operators
Operators /
Connectives
An operator or connective combines one or more operand
expressions into a larger expression. (E.g., “+” in numeric exprs.)

Formal Name Nickname Arity Symbol


Negation operator NOT Unary ¬
Conjunction operator AND Binary Ù
Disjunction operator OR Binary Ú
Exclusive-OR operator XOR Binary Å
Implication operator IMPLIES Binary ®
Biconditional operator IFF Binary ↔

7
Topic #1.0 – Propositional Logic: Operators

The Negation Operator


The unary negation operator “¬” (NOT)
p ¬p
¬ T F
F T
The binary conjunction operator “Ù” (AND)
p q pÙq
F F F

Ù F
T
T
F
F
F
T T T
¬ and Ù operations together are sufficient to
express any Boolean truth table!
8
Topic #1.0 – Propositional Logic: Operators

The Disjunction Operator


The binary disjunction operator “Ú” (OR).
p q pÚq
F F F
F T T
T F T
T T T
So, this operation is also called inclusive or, because
it includes the possibility that both p and q are true.

“¬” and “Ú” together are also universal.


9
Topic #1.0 – Propositional Logic: Operators

Nested Propositional
Expressions
• Use parentheses to group sub-expressions:
“I just saw my old friend, and either he’s
grown or I’ve shrunk.” = f Ù (g Ú s)
– (f Ù g) Ú s would mean something
different
– f Ù g Ú s would be ambiguous
• By convention, “¬” takes precedence over
both “Ù” and “Ú”.
– ¬s Ù f means (¬s) Ù f , not ¬ (s Ù f)
10
Topic #1.0 – Propositional Logic: Operators

A Simple Exercise
p=“It rained last night”,
q=“The sprinklers came on last night,”
r=“The lawn was wet this morning.”
Translate each of the following into English:
¬p = “It didn’t rain last night.”
r Ù ¬p = “The lawn was wet this morning, and
it didn’t rain last night.”
¬rÚpÚq =
“Either the lawn wasn’t wet this
morning, or it rained last night, or
the sprinklers came on last night.”
11
Topic #1.0 – Propositional Logic: Operators

The Exclusive Or Operator


Exclusive-or operator “Å” (XOR).
Exclusive or, because it excludes the p q pÅq
possibility that both p and q are true.
F F F
F T T
p = “I will earn an A in this course,”
T F T
q = “I will drop this course,”
T T F
p Å q = “I will either earn an A in this course, or I
will drop it (but not both!)”

“¬” and “Å” together are not universal.


12
Would you like a cup of tea
or coffee?

13
Topic #1.0 – Propositional Logic: Operators

Natural Language is
Ambiguous
Note that English “or” can be ambiguous
regarding the “both” case!
p q p "or" q
“Pat is a singer or
Pat is a writer.” - Ú F F F
“Pat is a man or F T T
Pat is a woman.” - Å T F T
T T ?
Need context to disambiguate the meaning!
For this class, assume “or” means inclusive.
14
Topic #1.0 – Propositional Logic: Operators

The Implication Operator


antecedent consequent

The implication p ® q states that p implies q.


I.e., If p is true, then q is true; but if p is
not true, then q could be either true or
false.
E.g., let p = “You study hard.”
q = “You will get a good grade.”
p ® q = “If you study hard, then you will get
a good grade.” (else, it could go either way)
15
Topic #1.0 – Propositional Logic: Operators

Implication Truth Table

• p ® q is false only when p q p®q


p is true but q is not true. F F T
• p ® q does not say
F T T The
that p causes q!
– Example?
T F F only
False
• p ® q does not require T T T case!
that p or q are ever true!
• E.g. “(1=0) ® pigs can fly” is TRUE!

16
Topic #1.0 – Propositional Logic: Operators

How do we know for sure?


Proving the equivalence of p ® q and its
contrapositive ¬q ® ¬ p using truth
tables:
p q ¬q ¬p p®q ¬q ®¬p
F F T T T T
F T F T T T
T F T F F F
T T F F T T

17
Topic #1.0 – Propositional Logic: Operators

The biconditional operator


The biconditional p « q states that
p is true if and only if (IFF) q is true. p q p«q
• p « q means that p and q F F T
have the same truth value.
F T F
• Note this truth table is the
exact opposite of Å’s! T F F
Thus, p « q means ¬(p Å q) T T T
• p « q does not imply
that p and q are true, or that either of them
causes the other, or that they have a common
cause.
18
Topic #1.0 – Propositional Logic: Operators

Boolean Operations Summary

p q ¬p pÙq pÚq pÅq p®q p«q


F F T F F F T T
F T T F T T T F
T F F F T T F F
T T F T T F T T

19
Topic #1.0 – Propositional Logic: Operators
Some Alternative
Notations

Name: not and or xor implies iff


Propositional logic: ¬ Ù Ú Å ® «
Boolean algebra: p pq + Å
C/C++/Java (wordwise): ! && || != ==
C/C++/Java (bitwise): ~ & | ^
Logic gates:

20
Topic #1.1 – Propositional Logic: Equivalences

Propositional Equivalence
(§1.2)
Two syntactically (i.e., textually) different
compound propositions may be the
semantically identical (i.e., have the same
meaning). We call them equivalent.
Learn:
• Various equivalence rules or laws.
• How to prove equivalences using
symbolic derivations.
21
Topic #1.1 – Propositional Logic: Equivalences

Tautologies and
Contradictions
A tautology is a compound proposition
that is true no matter what the truth
values of its atomic propositions are!
Ex. p Ú ¬p [What is its truth table?]
A contradiction is a compound proposition
that is false no matter what!
Ex. p Ù ¬p [Truth table?]

Other compound propositions are contingencies.


22
Topic #1.1 – Propositional Logic: Equivalences

Logical Equivalence
Compound proposition p is logically equivalent
to compound proposition q, written pÛq,
IFF
the compound proposition p«q is a tautology.

THAT IS: IFF All True or all False

p and q contain the same truth values as


each other in all rows of their truth
tables. 23
Topic #1.1 – Propositional Logic: Equivalences

Proving Equivalence
via Truth Tables

Ex. Prove that pÚq Û ¬(¬p Ù ¬q).

p q pÚq ¬p ¬q ¬p Ù ¬q ¬(¬p Ù ¬q)


F F F T T T F
F T T T F F T
T F T F T F T
T T T F F F T

24
Topic #1.1 – Propositional Logic: Equivalences

Equivalence Laws
• These are similar to the arithmetic
identities you may have learned in
algebra, but it is for propositional
equivalences instead.
• They provide a pattern or template
that can be used to match all or part of
a much more complicated proposition
and to find an equivalence for it.
25
Topic #1.1 – Propositional Logic: Equivalences

Equivalence Laws - Examples


• Identity: pÙT Û p pÚF Û p
• Domination: pÚT Û T pÙF Û F
• Idempotent: pÚp Û p pÙp Û p
• Double negation: ¬¬p Û p
• Commutative: pÚq Û qÚp pÙq Û qÙp
• Associative: (pÚq)Úr Û pÚ(qÚr)
(pÙq)Ùr Û pÙ(qÙr)

26
Topic #1.1 – Propositional Logic: Equivalences
More Equivalence pÚ(qÚr) (pÚq)Úr
Laws pÚ(qÙr) ?

• Distributive:
pÚ(qÙr) Û (pÚq)Ù(pÚr)
pÙ(qÚr) Û (pÙq)Ú(pÙr)
• De Morgan’s:
Augustus
¬(pÙq) Û ¬p Ú ¬q De Morgan
¬(pÚq) Û ¬p Ù ¬q (1806-1871)

• Trivial tautology/contradiction:
p Ú ¬p Û T p Ù ¬p Û F

27
Topic #1.1 – Propositional Logic: Equivalences

Defining Operators via Equivalences

Using equivalences, we can define operators


in terms of other operators.
• Exclusive or: pÅq Û (pÚq)Ù¬(pÙq)
pÅq Û (pÙ¬q)Ú(qÙ¬p)
• Implies: p® q Û ¬ p Ú q

• Biconditional:p«q Û (p®q) Ù (q®p)


p«q Û ¬(pÅq)
28
Topic #1.1 – Propositional Logic: Equivalences

An Example Problem
• Check using a symbolic derivation whether
(p Ù ¬q) ® (p Å r) Û ¬p Ú q Ú ¬r.
(p Ù ¬q) ® (p Å r) [Expand definition of ®]
Û ¬(p Ù ¬q) Ú (p Å r) [Expand defn. of Å]
Û ¬(p Ù ¬q) Ú ((p Ú r) Ù ¬(p Ù r))
[DeMorgan’s Law]
Û (¬p Ú q) Ú ((p Ú r) Ù ¬(p Ù r))
cont.

29
Topic #1.1 – Propositional Logic: Equivalences

Example Continued...
(¬p Ú q) Ú ((p Ú r) Ù ¬(p Ù r)) Û [Ú commutes]
Û (q Ú ¬p) Ú ((p Ú r) Ù ¬(p Ù r)) [Ú associative]
Û q Ú (¬p Ú ((p Ú r) Ù ¬(p Ù r))) [distrib. Ú over Ù]
Û q Ú (((¬p Ú (p Ú r)) Ù (¬p Ú ¬(p Ù r))) [assoc.]
Û q Ú (((¬p Ú p) Ú r) Ù (¬p Ú ¬(p Ù r))) [trivail taut.]
Û q Ú ((T Ú r) Ù (¬p Ú ¬(p Ù r))) [domination]
Û q Ú (T Ù (¬p Ú ¬(p Ù r))) [identity]
Û q Ú (¬p Ú ¬(p Ù r)) Û cont.

30
Topic #1.1 – Propositional Logic: Equivalences

End of Long Example


q Ú (¬p Ú ¬(p Ù r))
[DeMorgan’s] Û q Ú (¬p Ú (¬p Ú ¬r))
[Assoc.] Û q Ú ((¬p Ú ¬p) Ú ¬r)
[Idempotent] Û q Ú (¬p Ú ¬r)
[Assoc.] Û (q Ú ¬ p) Ú ¬ r
[Commut.] Û ¬p Ú q Ú ¬r
Q.E.D. (quod erat demonstrandum)
(Which was to be shown.)
31
Summary of
important
logical
equivalences I
Note
• T is the
compound
composition that
is always true
• F is the
compound
composition that
is always false.
32
Summary of
important
logical
equivalences II

33
Topic #1 – Propositional Logic

Review: Propositional Logic


(§§1.1-1.2-1.3)

• Atomic propositions: p, q, r, …
• Boolean operators: ¬ Ù Ú Å ® «
• Compound propositions:s :º (p Ù ¬q)Ú r
• Equivalences: pÙ¬q Û ¬(p ® q)
• Proving equivalences using:
– Truth tables.
– Symbolic derivations. p Û q Û r …

34
1/10/18 35

Vous aimerez peut-être aussi