Chap01 - Logic and Proof
Chap01 - Logic and Proof
(501215-3)
Chapter 1
The Foundations:
Logic and Proofs
1
1.1 Propositional Logic
1.2 Propositional Equivalences
1.3 Predicates and Quantifiers
1.4 Nested Quantifiers
1.6 Introduction to Proofs
1.7 Proof Methods and Strategy
2 P. 1
1.1 Propositional Logic
3
• Compound propositions: news
propositions formed from existing
propositions using logical operators
• Definition 1: Let p be a proposition. The
negation of p, denoted by p (orp), is the
statement “It is not the case that p.”
– “not p”
4
TABLE 1 (1.1)
5 P. 3
• Definition 2: Let p and q be propositions.
The conjunction of p and q, denoted by p
q, is the proposition “p and q.”
• Definition 3: Let p and q be propositions.
The disjunction of p and q, denoted by p q,
is the proposition “p or q.”
6
TABLE 2 (1.1)
7 P. 4
TABLE 3 (1.1)
8 P. 4
• 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.
9
TABLE 4 (1.1)
10 P. 6
Conditional Statements
11
TABLE 5 (1.1)
12 P. 6
Converse, Contrapositive, and Inverse
• pq
• Converse: q p
• Contrapositive: q p
• Inverse: p q
• 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
13
Example
• p is "I am in the University“, q is "It is
Tuesday"
"I am in Univ" → "It is If I am in Univ then it is
p→q
Tuesday" Tuesday
"It is Tuesday" → "I am If it is Tuesday then I
q→p
in Univ" am in Univ
"It is NOT Tuesday" → If it is NOT Tuesday
¬q → ¬p
"I am NOT in Univ" then I am NOT in Univ
"I am NOT in Univ" → If I am NOT in Univ
¬p → ¬q
"It is NOT Tuesday" then it is NOT Tuesday
14
Exercise
p q ¬p ¬q p → q q→p ¬p → ¬q ¬q → ¬p
F F
F T
T F
T T
15
Biconditionals
16
TABLE 6 (1.1)
17 P. 9
Implicit Use of Biconditionals
18
TABLE 7 (1.1)
19 P. 10
Precedence of Logical Operators
20
Examples
1. ¬p → q ↔ p ^ q r =
2. p ^ ¬q v p ↔ q → r ^ p
= ....
21 P. 11
Examples
p q pq p→q (p → q) (p q)
F F F T F
F T T T T
T F T F F
T T T T T
p q ¬p p→q (p → q) ^ ¬p
F F
F T
T F
T T
22
Translating English Sentences
23
Exercise
24
Exercise
25
Solution
• Boolean Searches
– New AND Mexico AND universities
– (Mexico AND universities) NOT New
• Logic Puzzles
– Ex. 18:
• Knights always tell the truth, and knaves always lie
• A says “B is a knight”
• B says “The two of us are opposite types”
• What are A and B?
– Ex. 19
27
Logic and Bit Operations
28
TABLE 9 (1.1)
29 P. 15
1.2 Propositional Equivalences
• Definition 1:
– Tautology: a compound proposition that is
always true
– Contradiction: a compound proposition that is
always false
– Contingency: a compound proposition that is
neither a tautology nor a contradiction
30
TABLE 1 (1.2)
31 P. 22
Logical Equivalence
33 P. 22
TABLE 3 (1.2)
34 P. 22
Example
• p is "Ahmad has a cell phone" ,
q is "Ahmad has a laptop computer."
• p q is "Ahmad has a cell phone." and "
Ahmad has a laptop computer."
• ¬(p q) is "Ahmad does not have a cell phone
and a laptop computer."
• ¬p ¬q is "Ahmad does not have a cell phone
or Ahmad does not have a laptop computer."
• ¬(p q) ≡ ¬p ¬q
35
TABLE 4 (1.2)
pq
36 P. 23
TABLE 5 (1.2)
37 P. 23
38 P. 24
TABLE 7 (1.2)
39 P. 25
TABLE 8 (1.2)
40 P. 25
Constructing New Logical Equivalence
41
Example
• Show that ¬(p ∨ (¬p ∧ q)) ≡ ¬p ∧¬q
- ¬(p ∨ (¬p ∧ q)) ≡ ¬p ∧¬(¬p ∧ q) . 2sd De Morgan law
≡ ¬p ∧ [¬(¬p)∨¬q] by the first De Morgan law
≡ ¬p ∧ (p ∨¬q) by the double negation law
≡ (¬p ∧ p) ∨ (¬p ∧¬q) by the second distributive law
≡ F ∨ (¬p ∧¬q) because ¬p ∧ p ≡ F
≡ (¬p ∧¬q) ∨ F by the commutative law for disjunction
≡ ¬p ∧¬q by the identity law for F
42
Exercise
43
1.3 Predicates and Quantifiers
• Predicate logic
• Predicate: a property that the subject of the
statement can have
– Ex: x>3
• x: variable
• >3: predicate
• P(x): x>3
– The value of the propositional function P at x
– P(x1,x2, …, xn): n-place predicate or n-ary
predicate
44
Quantifiers
• Quantification
– Universal quantification: a predicate is true for
every element
– Existential quantification: there is one or more
element for which a predicate is true
45
The Universal Quantifier
46
The Existential Quantifier
47
TABLE 1 (1.3)
48 P. 34
Other Quantifiers
49
• Precedence of quantifiers
– and have higher precedence than all
logical operators
– Ex: x P(x) Q(x)
• (x P(x)) Q(x)
50
Logical Equivalence involving
Quantifiers
51
Negating Quantified Expressions
52
TABLE 2 (1.3)
53 P. 41
Example
55
• Using Quantifiers in system specifications
– “Every mail message larger than one megabyte will be compressed”
• let S(m , y) ="Mail message m is larger than y megabytes," where
domain(x)={all mail messages}
• let y is a positive real number,
• let C (m )= "Mail message m will be compressed.“
• Specification: m (S(m , 1 ) C(m)).
– “If a user is active, at least one network link will be available”
• Let A(u) ="User u is active," where domain(u)={all users},
• let S(n , x) ="Network link n is in state x " ,domain(n) ={all network
links}, domain(x)={all possible states for a network link}
• Specification : u A(u) n S(n , available).
• Examples from Lewis Carroll: “All lions are fierce”, “Some lions do not
drink coffee”, Some fierce creatures do not drink coffee”
• Let P (x)="x is a lion," Q (x)="x is fierce," R (x)="x drinks coffee,"
respectively. Domain(x)={all creatures}
• x(P (x) Q (x)), x(P (x) R (x)), x(Q (x) R (x))
56
1.6 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
57
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.
58
Example
59
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
60
A little proof strategy
61
• 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.
62
Proof by Contradiction
63