Topic 1.1 1.3 Proposition and Equivalanece
Topic 1.1 1.3 Proposition and Equivalanece
Foundations: Logic
and Proofs
For Instruction Purpose only
WMSU Week 2
CPE 116 Discrete Mathematics
Heidee L. Soliman, MEng’g CpE
4
Introduction
• Logic
– is the study of the logic relationships between
objects and
– forms the basis of all mathematical reasoning and
all automated reasoning
5
PROPOSITIONS
1.1 Propositional Logic
6
● A proposition is a declarative sentence (a
sentence that declares a fact) that is either
true or false, but not both.
● Are the following sentences propositions?
○ Toronto is the capital of Canada. (Yes)
○ Read this carefully. (No)
○ 1+2=3 (Yes)
○ x+1=2 (No)
○ What time is it? (No)
7
● Propositional Logic – the area of logic that
deals with propositions
● Propositional Variables – variables that
represent propositions: p, q, r, s
○ E.g. Proposition p – “Today is Friday.”
● Truth values – T, F
8
DEFINITION 1
Let p be a proposition. The negation of p, denoted by ¬p, is the statement
“It is not the case that p.”
The proposition ¬p is read “not p.” The truth value of the negation of p, ¬p
is the opposite of the truth value of p.
● Examples
○ Find the negation of the proposition “Today is Friday.” and
express this in simple English.
Solution: The negation is “It is not the case that today is Friday.”
In simple English, “Today is not Friday.” or “It is not Friday today.”
○ Find the negation of the proposition “At least 10 inches of rain fell
today in Miami.” and express this in simple English.
Solution: The negation is “It is not the case that at least 10 inches of rain fell
today in Miami.”
In simple English, “Less than 10 inches of rain fell today in Miami.”
9
● Note: Always assume fixed times, fixed places, and particular people
unless otherwise noted.
● Truth table:
The Truth Table for the
Negation of a Proposition.
p ¬p
T F
F T
● Logical operators are used to form new propositions from two or
more existing propositions. The logical operators are also called
connectives.
10
DEFINITION 2
Let p and q be propositions. The conjunction of p and q, denoted by p Λ
q, is the proposition “p and q”. The conjunction p Λ q is true when both
p and q are true and is false otherwise.
● Examples
○ Find the conjunction of the propositions p and q where p is the
proposition “Today is Friday.” and q is the proposition “It is raining
today.”, and the truth value of the conjunction.
Solution: The conjunction is the proposition “Today is Friday and it
is raining today.” The proposition is true on rainy Fridays.
11
DEFINITION 3
Let p and q be propositions. The disjunction of p and q, denoted by p ν
q, is the proposition “p or q”. The conjunction p ν q is false when both p
and q are false and is true otherwise.
● Note:
inclusive or : The disjunction is true when at least one of the two
propositions is true.
○ E.g. “Students who have taken calculus or computer science can take
this class.” – those who take one or both classes.
exclusive or : The disjunction is true only when one of the
proposition is true.
○ E.g. “Students who have taken calculus or computer science, but not
both, can take this class.” – only those who take one of them.
● Definition 3 uses inclusive or.
12
DEFINITION 4
Let p and q be propositions. The exclusive or of p and q, denoted by p ⊕q,
is the proposition that is true when exactly one of p and q is true and is
false otherwise. ⊕
The Truth Table for The Truth Table for The Truth Table for the
the Conjunction of the Disjunction of Exclusive Or (XOR) of
Two Propositions. Two Propositions. Two Propositions.
p q pΛq p q pνq p q p ⊕q
T T T T T T T T F
T F F T F T T F T
F T F F T T F T T
F F F F F F F F F
13
CONDITIONAL
STATEMENTS
1.1 Propositional Logic
14
DEFINITION 5
Let p and q be propositions. The conditional statement p → q, is the
proposition “if p, then q.” The conditional statement is false when p is
true and q is false, and true otherwise. In the conditional
⊕
statement p
→ q, p is called the hypothesis (or antecedent or premise) and q is
called the conclusion (or consequence).
15
Logical Connective: Implication (2)
• The implication of p→q
can be also read as
– If p then q
– p implies q
– If p, q
– p only if q
– q if p
– q when p
– q whenever p
– q follows from p
– p is a sufficient condition
for q (p is sufficient for q)
– q is a necessary condition
for p (q is necessary for p)
16
Logical Connective: Implication (3)
• Examples
– If you buy you air ticket in advance, it is
cheaper.
– If x is an integer, then x2 ≥ 0.
– If it rains, the grass gets wet.
– If the sprinklers operate, the grass gets wet.
– If 2+2=5, then all unicorns are pink.
17
● Example:
○ Let p be the statement “Maria learns discrete mathematics.” and
q the statement “Maria will find a good job.” Express the
statement p → q as a statement in English.
Solution: Any of the following -
“If Maria learns discrete mathematics, then she will find a
good job.
“Maria will find a good job when she learns discrete
mathematics.”
“For Maria to get a good job, it is sufficient for her to
learn discrete mathematics.”
“Maria will find a good job unless she does not learn
discrete mathematics.”
18
CONVERSE, CONTRAPOSITIVE, AND INVERSE
● Other conditional statements:
○ Converse of p → q : q → p
○ Contrapositive of p → q : ¬ q → ¬ p
○ Inverse of p → q : ¬ p → ¬ q
● Example:
○ What are the contrapositive, the converse, and the inverse of the
conditional statement
“The home team wins whenever it is raining?”
Solution
○ Converse “If the home team wins, then it is raining.”
○ Contrapositive “If the home team does not win, then it is not
raining.”
○ Inverse “If it is not raining, then the home team does not win.”
19
BICONDITIONALS
DEFINITION 6
Let p and q be propositions. The biconditional statement p ↔ q is the
proposition “p if and only if q.” The biconditional statement p ↔ q is true
when p and q have the same truth values, and is false otherwise.
Biconditional statements are also called bi-implications.
20
The Truth Table for the
Biconditional p ↔ q.
p q p↔ q
T T T
T F F
F T F
F F T
21
Logical Connective: Biconditional (2)
• The biconditional p↔q can be equivalently
read as
– p if and only if q
– p is a necessary and sufficient condition for q
– if p then q, and conversely
– p iff q (Note typo in textbook, page 9, line 3)
• Examples
– x>0 if and only if x2 is positive
– The alarm goes off iff a burglar breaks in
– You may have pudding iff you eat your meat
22
Exercise: Which of the following biconditionals is true?
• x2 ≥ 0 if and only if x ≥ 0
False. The implication “if x ≥ 0 then x2 ≥ 0” holds.
However, the implication “if x2 ≥ 0 then x ≥ 0” is false.
Consider x=-1.
The hypothesis (-1)2=1 ≥ 0 but the conclusion fails.
23
TRUTH TABLES OF
COMPOUND
PROPOSITIONS
1.1 Propositional Logic
24
● We can use connectives to build up complicated compound
propositions involving any number of propositional variables, then
use truth tables to determine the truth value of these compound
propositions.
● Example: Construct the truth table of the compound proposition
(p ν ¬q) → (p Λ q).
T T F T T T
T F T T F F
F T F F F T
F F T T F F
25
Constructing Truth Tables
• Construct the truth table for the following
compound proposition
(( p ∧ q )∨ ¬q )
p q p∧q ¬q (( p ∧ q )∨ ¬q )
0 0 0 1 1
0 1 0 0 0
1 0 0 1 1
1 1 1 0 1
26
PRECEDENCE OF
LOGICAL
OPERATORS
1.1 Propositional Logic
27
● We can use parentheses to specify the order in which logical
operators in a compound proposition are to be applied.
● To reduce the number of parentheses, the precedence order is
defined for logical operators.
¬ 1 p ν q Λ r = p ν (q Λ r)
Λ 2
ν 3
→ 4
↔ 5
28
LOGIC AND BIT
OPERATIONS
1.1 Propositional Logic
29
Truth Value BIT
T 1
● Computers represent information using bits. F 0
● A bit is a symbol with two possible values, 0 and 1.
● By convention, 1 represents T (true) and 0 represents F (false).
● A variable is called a Boolean variable if its value is either true or
false.
● Bit operation – replace true by 1 and false by 0 in logical operations.
0 0 0 0 0
0 1 1 0 1
1 0 1 0 1
1 1 1 1 0
30
DEFINITION 7
A bit string is a sequence of zero or more bits. The length of this string
is the number of bits in the string.
● Example: Find the bitwise OR, bitwise AND, and bitwise XOR of the
bit string 01 1011 0110 and 11 0001 1101.
Solution:
01 1011 0110
11 0001 1101
-------------------
11 1011 1111 bitwise OR
01 0001 0100 bitwise AND
10 1010 1011 bitwise XOR
31
1.2 APPLICATIONS
OF PROPOSITIONAL
LOGIC
32
Translating English Sentences
● English (and every other human language) is often ambiguous.
Translating sentences into compound statements removes the
ambiguity.
● Example: 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.” The sentence can be translated into:
(r Λ ¬ s) → ¬q.
33
● Example: How can this English sentence be translated into a logical
expression?
“You can access the Internet from campus only if you are a
computer engineering major or you are not a freshman.”
Solution: Let a, c, and f represent “You can access the Internet from
campus,” “You are a computer engineering major,” and “You are
a freshman.” The sentence can be translated into:
a → (c ν ¬f).
34
System Specifications
• System and software engineers take requirements in natural
language and produce precise and unambiguous specifications
that can be used as the basis for system development.
● Example: Express the specification “The automated reply cannot be sent
when the file system is full” using logical connectives.
● Solution:
● let p denote “The automated reply can be sent” and
● q denote “The file system is full.”
● Then ¬p represents “It is not the case that the automated reply
can be sent,” which can also be expressed as “The automated
reply cannot be sent.”
● Consequently, our specification can be represented by the
conditional statement q → ¬p.
35
Boolean Searches
• Logical connectives are used extensively in searches of large
collections of information, such as indexes of Web pages.
Because these searches employ techniques from propositional
logic, they are called Boolean searches.
• In Boolean searches, the connective AND is used to match
records that contain both of two search terms, the connective OR
is used to match one or both of two search terms, and the
connective NOT (sometimes written as AND NOT ) is used to
exclude a particular search term.
• Example: Web Page Searching
• MostWeb search engines support Boolean searching
techniques, which is useful for findingWeb pages about
particular subjects.
36
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.
• 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.
• Complicated digital circuits can be constructed from three
basic circuits, called gates, shown in Figure 1.
37
1.3 PROPOSITIONAL
EQUIVALENCES
38
Introduction
DEFINITION 1
A compound proposition that is always true, no matter what the truth
values of the propositions that occurs in it, is called a tautology. A
compound proposition that is always false is called a contradiction. A
compound proposition that is neither a tautology or a contradiction is
called a contingency.
T F T F
F T T F
39
Logical Equivalences
DEFINITION 2
The compound propositions p and q are called logically equivalent if p ↔
q is a tautology. The notation p ≡ q denotes that p and q are logically
equivalent.
40
Logical Equivalences
● Example 1:
Show that ¬(p ν q) and ¬p Λ ¬q are logically equivalent.
De Morgan’s Law
¬(p Λ q) ≡ ¬p ν ¬q
¬(p ν q) ≡ ¬p Λ ¬q
41
Logical Equivalences
● Example 2:
Show that ¬p ν q and p → q are logically equivalent. (This is known
as the conditional disjunction equivalence.)
42
● Example 3:
Show that p ∨ (q ∧ r) and (p ∨ q) ∧ (p ∨ r) are logically equivalent.
This is the distributive law of disjunction over conjunction.
43
Tables of Logical Equivalences
⬥ Identity laws
Like adding 0
⬥ Domination laws
Like multiplying by 0
⬥ Idempotent laws
Delete redundancies
⬥ Double negation
“I don’t like you, not”
⬥ Commutativity
Like “x+y = y+x”
⬥ Associativity
Like “(x+y)+z = y+(x+z)”
⬥ Distributivity
Like “(x+y)z = xz+yz”
⬥ De Morgan
L3 44
45
Logical Equivalences: Seatwork
• Construct the truth table of the given below
(p → r) ∨ (q → r) ≡ (p ∧ q) → r
p q r p→ r q→ r (p→ r) ∨ (q → r) p∧q (p ∧ q) → r
0 0 0 1 1 1 0 1
0 0 1 1 1 1 0 1
0 1 0 1 0 1 0 1
0 1 1 1 1 1 0 1
1 0 0 0 1 1 0 1
1 0 1 1 1 1 0 1
1 1 0 0 0 0 1 0
1 1 1 1 1 1 1 1 46
Using Logical Equivalences: Example 1
• Logical equivalences can be used to construct
additional logical equivalences
• Example: Show that (p ∧ q) →q is a tautology
0. (p ∧ q) →q
1. ≡ ¬(p ∧ q) ∨ q Implication Law on 0
2. ≡ (¬p ∨ ¬q) ∨ q De Morgan’s Law (1st) on 1
3. ≡ ¬p ∨ (¬q ∨ q) Associative Law on 2
4. ≡ ¬p ∨ 1 Negation Law on 3
5. ≡ 1 Domination Law on 4
47
Suggested Steps
• Remove double implication
• Replace implication by disjunction
• Push negation inwards
• Distribute
48
Using Logical Equivalences: Example 2
• Example: Show that ¬(p → q) and (p ∧ ¬q) are logically
equivalent
49
Using Logical Equivalences: Example 3
• Example: Show that ¬(p ∨(¬p ∧ q) and ¬p ∧ ¬q are logically
equivalent by developing a series of logical equivalences
50
Using Logical Equivalences: Example 4
• Example: Show that ¬(p ↔ q) ≡ (p ↔ ¬q)
• Sometimes it helps to start with the second proposition (p ↔ ¬q)
0. (p ↔ ¬q)
1. ≡ (p → ¬q) ∧ (¬q → p) Equivalence Law on 0
2. ≡ (¬p ∨ ¬q) ∧ (q ∨ p) Implication Law on 1
3. ≡ ¬(¬((¬p ∨ ¬q) ∧ (q ∨ p))) Double negation on 2
4. ≡ ¬(¬(¬p ∨ ¬q) ∨ ¬(q ∨ p)) De Morgan’s Law…
5. ≡ ¬((p ∧ q) ∨ (¬q ∧ ¬p)) De Morgan’s Law
6. ≡ ¬((p ∨ ¬q) ∧ (p ∨ ¬p) ∧ (q ∨ ¬q) ∧ (q ∨ ¬p)) Distribution Law
7. ≡ ¬((p ∨ ¬q) ∧ (q ∨ ¬p)) Identity Law
8. ≡ ¬((q → p ) ∧ (p → q)) Implication Law
9. ≡ ¬(p ↔ q) Equivalence Law
51
Using Logical Equivalences: Example 5
• Show that ¬(q → p) ∨ (p ∧ q) ≡ q
0. ¬(q → p) ∨ (p ∧ q)
1. ≡ ¬(¬q ∨ p) ∨ (p ∧ q) Implication Law
2. ≡ (q ∧ ¬p) ∨ (p ∧ q) De Morgan’s & Double Negation
3. ≡ (q ∧ ¬p) ∨ (q ∧ p) Commutative Law
4. ≡ q ∧ (¬p ∨ p) Distributive Law
5. ≡ q ∧ 1 Identity Law
≡q Identity Law
52
Proving Logical Equivalences: Summary
• Proving two PL sentences A,B are equivalent using TT +
EL
1. Verify that the 2 columns of A, B in the truth table are the same
(i.e., A,B have the same models)
2. Verify that the column of (A→B ∧ B→A) in the truth table has
all-1 entries (it is a tautology)
3. Put A,B in CNF, they should be the same
• Sequence of equivalence laws: Biconditional, implication, moving
negation inwards, distributivity
4. Apply a sequence of inference laws
• Starting from one sentence, usually the most complex one,
• Until reaching the second sentence
• Typical sequence: Biconditional, implication, moving negation
inwards, distributivity
53
Seatwork/Assignment
Find the logical equivalence of the following
statement:
1. (P ∧ Q) → (P ∨ Q)
2. (¬P ∧( P → Q)) → ¬Q
54
QUIZ NEXT
MEETING
Next topic: 1.4 Predicate and Quantifiers
55