Discrete Mathematics and Its ApplicationsLecture 1: The Foundations: Logic and Proofs (1.3-1.5)
MING GAO
DASE @ ECNU(for course related communications)
Sep. 19, 2017
Outline
1 Logical Equivalences
2 Propositional Satisfiability
3 Predicates
4 Quantifiers
5 Applications of Quantifiers
6 Nested Quantifiers
7 Take-aways
MING GAO (DaSE@ECNU) Discrete Mathematics and Its Applications Sep. 19, 2017 2 / 28
Logical Equivalences
Motivation
Example
There are two kinds of inhabitants in an island, knights, who alwaystell the truth, knaves, who always lie. You encounter two people Aand B. What are A and B if A says “B is a knight” and B says “Thetwo of us are opposite types”?Solution:
p : “A is a knight;”
q : “B is a knight;”
If A is a knight, we have p ∧ q ∧ ((¬p ∧ q) ∨ (p ∧ ¬q)).
If A is a knave, we have ¬p ∧ ¬q ∧ ((p ∧ q) ∨ (¬p ∧ ¬q)).
The problem is how to determine the truth value of the propositions.
MING GAO (DaSE@ECNU) Discrete Mathematics and Its Applications Sep. 19, 2017 3 / 28
Logical Equivalences
Logical equivalences
Definition
Compound propositions that have the same truth values in all possiblecases are called logically equivalent.
Compound propositions p and q are called logically equivalent ifp ↔ q is a tautology, denoted as p ≡ q or p ⇔ q.
Remark: Symbol ≡ is not a logical connectives, and p ≡ q is not aproposition.
One way to determine whether two compound propositions areequivalent is to use a truth table.
MING GAO (DaSE@ECNU) Discrete Mathematics and Its Applications Sep. 19, 2017 4 / 28
Logical Equivalences
De Morgan’s laws
Laws
¬(p ∧ q) ≡ ¬p ∨ ¬q
¬(p ∨ q) ≡ ¬p ∧ ¬q
¬(p1 ∧ p2 ∧ · · · ∧ pn) ≡ ¬p1 ∨ ¬p2 ∨ ¬ · · · ∨ ¬pn, i.e.,¬∧n
i=1 pi ≡∨n
i=1 ¬pi .
¬(p1 ∨ p2 ∨ · · · ∨ pn) ≡ ¬p1 ∧ ¬p2 ∧ ¬ · · · ∧ ¬pn, i.e.,¬∨n
i=1 pi ≡∧n
i=1 ¬pi .
The truth table can be used to determine whether two compoundpropositions are equivalent.
p q p ∧ q ¬(p ∧ q) ¬p ¬q ¬p ∨ ¬q
T T T F F F FT F F T F T TF T F T T F TF F F T T T T
MING GAO (DaSE@ECNU) Discrete Mathematics and Its Applications Sep. 19, 2017 5 / 28
Logical Equivalences
Logical equivalence
Table of logical equivalence
equivalence name
p ∧ T ≡ p Identity lawsp ∨ F ≡ p
p ∧ p ≡ p Idempotent lawsp ∨ p ≡ p
(p ∧ q) ∧ r ≡ p ∧ (q ∧ r) Associative laws(p ∨ q) ∨ r ≡ p ∨ (q ∨ r)
p ∨ (p ∧ q) ≡ p Absorption lawsp ∧ (p ∨ q) ≡ p
p ∧ ¬p ≡ F Negation lawsp ∨ ¬p ≡ T
MING GAO (DaSE@ECNU) Discrete Mathematics and Its Applications Sep. 19, 2017 6 / 28
Logical Equivalences
Logical equivalence Cont’d
Table of logical equivalence
equivalence name
p ∨ T ≡ T Domination lawsp ∧ F ≡ F
p ∧ q ≡ q ∧ p Commutative lawsp ∨ q ≡ q ∨ p
(p ∧ q) ∨ r ≡ (p ∨ r) ∧ (q ∨ r) Distributive laws(p ∨ q) ∧ r ≡ (p ∧ r) ∨ (q ∧ r)
¬(p ∧ q) ≡ ¬p ∨ ¬q De Morgan’s laws¬(p ∨ q) ≡ ¬p ∧ ¬q
¬(¬p) ≡ p Double negation law
MING GAO (DaSE@ECNU) Discrete Mathematics and Its Applications Sep. 19, 2017 7 / 28
Logical Equivalences
Equivalence of implication
Equivalence law
p → q ≡ ¬p ∨ qThe truth table can be used to determine whether two compoundpropositions are equivalent.
p q p → q ¬p ¬p ∨ q
T T T F TT F F F FF T T T TF F T T T
MING GAO (DaSE@ECNU) Discrete Mathematics and Its Applications Sep. 19, 2017 8 / 28
Logical Equivalences
Logical equivalences involving conditional statements
Table of logical equivalences involving conditional statements
p → q ≡ ¬p ∨ q
p → q ≡ ¬q → ¬p
p ∨ q ≡ ¬p → q
p ∧ q ≡ ¬(p → ¬q)
¬(p → q) ≡ p ∧ ¬q
(p → q) ∧ (p → r) ≡ p → (q ∧ r)
(p → q) ∨ (p → r) ≡ p → (q ∨ r)
(p → r) ∧ (q → r) ≡ (p ∧ q)→ r
(p → r) ∨ (q → r) ≡ (p ∨ q)→ r
MING GAO (DaSE@ECNU) Discrete Mathematics and Its Applications Sep. 19, 2017 9 / 28
Logical Equivalences
Logical equivalences involving biconditional statements
Table of logical equivalences involving biconditional statements
p ↔ q ≡ (p → q) ∧ (q → p)
p ↔ q ≡ ¬p ↔ ¬q
p ↔ q ≡ (p ∧ q) ∨ (¬p ∧ ¬q)
¬(p ↔ q) ≡ p ↔ ¬q
Show that ¬(p ↔ q) and p ↔ ¬q are logically equivalent.
¬(p ↔ q) ≡ ¬((¬p ∨ q) ∧ (¬q ∨ p))
≡ (p ∧ ¬q) ∨ (q ∧ ¬p)
≡ (p ∨ (q ∧ ¬p)) ∧ (¬q ∨ (q ∧ ¬p))
≡ ((p ∨ q) ∧ (p ∨ ¬p)) ∧ ((¬q ∨ q) ∧ (¬q ∨ ¬p))
≡ (¬(¬q) ∨ p) ∧ (¬p ∨ ¬q))
≡ (¬q → p) ∧ (p → ¬q)) ≡ p ↔ ¬q (1)
MING GAO (DaSE@ECNU) Discrete Mathematics and Its Applications Sep. 19, 2017 10 / 28
Propositional Satisfiability
Propositional satisfiability
Definition
A compound proposition is satisfiable if there is an assignment of truthvalues to its variables that makes it true.
Determine whether each of the compound propositions(p ∨ ¬q) ∧ (q ∨ ¬r) ∧ (r ∨ ¬p).
(p ∨ ¬q) ∧ (q ∨ ¬r) ∧ (r ∨ ¬p) ≡ (q → p) ∧ (r → q) ∧ (p → r)
Note that (p ∨¬q)∧ (q ∨¬r)∧ (r ∨¬p) is true when the three variable p,q, and r have the same truth value.Hence, it is satisfiable as there is at least one assignment of truth valuesfor p, q, and r that makes it true.
MING GAO (DaSE@ECNU) Discrete Mathematics and Its Applications Sep. 19, 2017 11 / 28
Propositional Satisfiability
Applications of satisfiability
Sudoku puzzle
For each cell with a given value, we as-sert p(i , j , n) when the cell in row i andcolumn j has the given value n.
For every row, we assert:∧9
i=1
∧9n=1
∨9j=1 p(i , j , n);
For every column, we assert:∧9
j=1
∧9n=1
∨9i=1 p(i , j , n);
For every block, we assert it contains every number:∧2r=0
∧2s=0
∧9n=1
∨3i=1
∨3j=1 p(3r + i , cs + j , n);
To assert that no cell contains more than one number, we take theconjunction over all values of n, n
′, i , and j where each variable
ranges from 1 to 9 and n 6= n′
of p(i , j , n)→ ¬p(i , j , n′).
MING GAO (DaSE@ECNU) Discrete Mathematics and Its Applications Sep. 19, 2017 12 / 28
Predicates
Motivation I
In many cases, the statement we are interested in contains variables.
Example
“e is even”, “p is prime”, or “s is a student”.As we previously did with propositions, we can use variables to rep-resent these statements.
E (x) : “x is even”;
P(y) : “y is prime”;
S(w) : “w is a student”.
You can think of E (x), P(y) and S(w) as statements that may betrue of false depending on the values of its variables.
MING GAO (DaSE@ECNU) Discrete Mathematics and Its Applications Sep. 19, 2017 13 / 28
Predicates
Motivation II
Example
“Every computer connected to the university network isfunctioning properly.”No rules of propositional logic allow us to conclude the truth ofthe statement“MATH3 is functioning properly, if MATH3 is one of thecomputers connected to the university network.”
Likewise, we cannot use the rules of propositional logic toconclude from the statement“CS2 is under attack by an intruder, and CS2 is a computer onthe university network.”We can conclude the truth of “There is a computer on theuniversity network that is under attack by an intruder.”
Predicate logic is a more powerful type of logic theory.
MING GAO (DaSE@ECNU) Discrete Mathematics and Its Applications Sep. 19, 2017 14 / 28
Predicates
Predicates
Definition
“x is greater than 3” has two parts: variable x (the subject of thestatement), and predicate P “is greater than 3”, denoted as P(x) : x > 3.
Statement P(x) is the value of the propositional function P at x ;
Once variable x is fixed, statement P(x) becomes a proposition andhas a truth value. e.g., P(4) (true) and P(2) (false)
Let A(x) denote “Computer x is under attack by an intruder”.Assume that CS2 in the campus is currently under attack byintruders. What are truth values of A(CS1), and A(CS2)?
Let Q(x , y) denote the statement “x = y + 3”. What are the truthvalues of the propositions Q(1, 2) and Q(3, 0)?
In general, a statement involving n variables x1, x2, · · · , xn can be denotedby P(x1, x2, · · · , xn), where P is also called an n-place predicate or a n-arypredicate, and x1, x2, · · · , xn is a n-tuple.
MING GAO (DaSE@ECNU) Discrete Mathematics and Its Applications Sep. 19, 2017 15 / 28
Quantifiers
Quantifiers
Quantification
Quantification expresses the extent to which a predicate is true over arange of elements. In general, all values of a variable is called the domainof discourse (or universe of discourse), just referred to as domain.
1 The universal quantification of P(x) is the statement “P(x) for allvalues of x in the domain”. Notation ∀xP(x) denotes the universalquantification of P(x), where ∀ is called the universal quantifier. Anelement for which P(x) is false is called a counterexample of ∀xP(x).
2 The existential quantification of P(x) is the proposition “There existsan element x in the domain such that P(x)”. Notation ∃xP(x)denotes the existential quantification of P(x), where ∃ is called theexistential quantifier.
Statement When True? When False?
∀xP(x) P(x) is true for every x ∃x for which P(x) is false∃xP(x) ∃x for which P(x) is true P(x) is false for every x
MING GAO (DaSE@ECNU) Discrete Mathematics and Its Applications Sep. 19, 2017 16 / 28
Quantifiers
Examples
Universal quantification
1 Let P(x) be “x + 1 > x”. What is the truth value of ∀xP(x) for∀x ∈ R?Note that if the domain is empty, then ∀xP(x) is true for anypropositional function P(x) because there are no elements x in thedomain for which P(x) is false.
2 Let P(x) be “x2 > 0”. What is the truth value of ∀xP(x) for ∀x ∈ Z ?(Note that x = 0 is a counterexample because x2 = 0 when x = 0)
Existential quantification
1 Let P(x) denote “x > 3”. What is the truth value of ∃xP(x) for∀x ∈ R?
2 Let P(x) be “x2 > 0”. What is the truth value of ∃xP(x) for ∀x ∈ Z ?
MING GAO (DaSE@ECNU) Discrete Mathematics and Its Applications Sep. 19, 2017 17 / 28
Quantifiers
Remarks
When all the elements in the domain can be listed as x1, x2, · · · , xnUniversal quantification
∀xP(x) is the same as conjunction
P(x1) ∧ P(x2) ∧ · · · ∧ P(xn),
because this conjunction is true if and only if P(x1), P(x2), · · · ,P(xn) areall true.
Existential quantification
∃xP(x) is the same as disjunction
P(x1) ∨ P(x2) ∨ · · · ∨ P(xn),
since the disjunction is true if and only if at least one of P(x1),P(x2), · · · ,P(xn) is true.
MING GAO (DaSE@ECNU) Discrete Mathematics and Its Applications Sep. 19, 2017 18 / 28
Quantifiers
Quantifiers with restricted domains
Example
What do the statements ∀x < 0(x2 > 0) and ∃y > 0(y 2 = 2) mean,where the domain in each case consists of the real numbers?
1 The statement ∀x < 0(x2 > 0) states that for every real number xwith x < 0, x2 > 0, i.e., it states “The square of a negative realnumber is positive”. This statement is the same as∀x(x < 0→ x2 > 0).
2 The statement ∃y > 0(y 2 = 2) states “There is a positive square rootof 2”, i.e., ∃y(y > 0 ∧ y 2 = 2).
Note that the restriction of a universal quantification is the same asthe universal quantification of a conditional statement.
On the other hand, the restriction of an existential quantification isthe same as the existential quantification of a conjunction.
MING GAO (DaSE@ECNU) Discrete Mathematics and Its Applications Sep. 19, 2017 19 / 28
Quantifiers
Precedence of quantifiers and binding variables
Precedence of quantifiers
The quantifiers ∀ and ∃ have higher precedence than all logical operatorsfrom propositional calculus.
∀xP(x) ∧ Q(x) ≡ (∀xP(x)) ∧ Q(x), rather than ∀x(P(x) ∧ Q(x)).
∃xP(x) ∨ Q(x) ≡ (∃xP(x)) ∨ Q(x).
Bound and free
In statement ∃x(x + y = 1), variable x is bound by the existentialquantification ∃x , but variable y is free because it is not bound by aquantifier and no value is assigned to this variable. This illustrates that inthe statement, x is bound, but y is free.The part of a logical expression to which a quantifier is applied is calledthe scope of this quantifier. Consequently, a variable is free if it is outsidethe scope of all quantifiers in the formula that specify this variable.
MING GAO (DaSE@ECNU) Discrete Mathematics and Its Applications Sep. 19, 2017 20 / 28
Quantifiers
Logical equivalences involving quantifiers
Definition
Statements involving predicates and quantifiers are logically equivalent ifand only if they have the same truth value no matter which predicates aresubstituted into these statements and which domain of discourse is usedfor the variables in these propositional functions. We use the notationS ≡ T to indicate that two statements S and T involving predicates andquantifiers are logically equivalent.
Table of logical equivalence
equivalence name
∀x(P(x) ∧ Q(x)) ≡ ∀xP(x) ∧ ∀xQ(x) Distributive law
¬∀xP(x) ≡ ∃x¬P(x) Negation law¬∃xP(x) ≡ ∀x¬P(x)
¬∀x(P(x)→ Q(x)) ≡ ∃x(P(x) ∧ ¬Q(x))
MING GAO (DaSE@ECNU) Discrete Mathematics and Its Applications Sep. 19, 2017 21 / 28
Applications of Quantifiers
Quantifiers in system specifications
Example
Use predicates and quantifiers to express the system specifications “Everymail message larger than one megabyte will be compressed” and “If a useris active, at least one network link will be available.”
Let S(m, y) be “Mail message m is larger than y megabytes,” wherevariable x has the domain of all mail messages and variable y is apositive real number, and let C (m) denote “Mail message m will becompressed.” Then “Every mail message larger than one megabytewill be compressed” can be represented as ∀m(S(m, 1)→ C (m)).
Let A(u) represent “User u is active,” where variable u has thedomain of all users, let S(n, x) denote “Network link n is in state x ,”where n has the domain of all network links and x has the domain ofall possible states for a network link. Then “If a user is active, at leastone network link will be available” can be represented by∃uA(u)→ ∃nS(n, available).
MING GAO (DaSE@ECNU) Discrete Mathematics and Its Applications Sep. 19, 2017 22 / 28
Nested Quantifiers
Nested quantifiers
Definition
Nested quantifiers is one quantifier within the scope of another.For example, ∀x∃y(x + y = 0). Note that everything within the scope of aquantifier can be thought of as a propositional function.∀x∃y(x + y = 0) is the same thing as ∀xQ(x), where Q(x) is ∃yP(x , y),where P(x , y) is x + y = 0.Please translate following nested quantifiers into statements
∀x∀y(x + y = y + x) for ∀x , y ∈ R.
∀x∃y(x + y = 0) for ∀x , y ∈ R.
∀x∀y∀z((x + y) + z = x + (y + z)) for ∀x , y , z ∈ R.
∀x∀y((x > 0) ∧ (y > 0)→ (xy < 0)) for ∀x , y ∈ R.
∀ε > 0∃δ > 0∀x(0 < |x − a| < δ → |f (x)− L| < ε).
MING GAO (DaSE@ECNU) Discrete Mathematics and Its Applications Sep. 19, 2017 23 / 28
Nested Quantifiers
Order of quantifiers
Order is important
It is important to note that the order of the quantifiers is important, unlessall the quantifiers are universal quantifiers or all are existential quantifiers.
Statement When True? When False?
∀x∀yP(x , y) P(x , y) is true There is a pair x , y for∀y∀xP(x , y) for every pair x , y which P(x , y) is false
∀x∃yP(x , y) For every x , there is a y There is an x such thatfor which P(x , y) is true P(x , y) is false for ∀y
∃x∀yP(x , y) There is an x for which For every x , there is a yP(x , y) is true for every y for which P(x , y) is false
∃x∃yP(x , y) There is a pair x , y P(x , y) is false∃y∃xP(x , y) for which P(x , y) is true for every pair x , y
MING GAO (DaSE@ECNU) Discrete Mathematics and Its Applications Sep. 19, 2017 24 / 28
Nested Quantifiers
Applications of nested quantifiers
Nested quantifiers translation
∀x(C (x) ∨ ∃y(C (y) ∧ F (x , y)))
C (x): x has a computer;
F (x , y): x and y are friends;
Domain for both x and y consists of all students in your school.
Solution:The statement says that for every student x in your school, x has acomputer or there is a student y such that y has a computer and x and yare friends.That is, every student in your school has a computer or has a friend whohas a computer.
MING GAO (DaSE@ECNU) Discrete Mathematics and Its Applications Sep. 19, 2017 25 / 28
Nested Quantifiers
Applications of nested quantifiers Cont’d
Sentence translation I
“If a person is female and is a parent, then she is someones mother”.Solution:∀x((F (x) ∧ P(x))→ ∃yM(x , y))
F (x): x is female;
P(x): x is a parent;
M(x , y): x is the mother of y ;
Sentence translation II
“There is a woman who has taken a flight on every airline in the world”.Solution:∃w∀a∃f (P(w , f ) ∧ Q(f , a))
P(w , f ): w has taken f ;
Q(f , a): f is a flight on a;
Or∃w∀a∃fR(w , f , a)
R(w , f , a): w has taken f on a.
MING GAO (DaSE@ECNU) Discrete Mathematics and Its Applications Sep. 19, 2017 26 / 28
Nested Quantifiers
Negation of nested quantifiers
Example
Use quantifiers to express the statement that “There does not exist awoman who has taken a flight on every airline in the world”¬∃w∀a∃f (P(w , f ) ∧ Q(f , a))
P(w , f ): w has taken f ;
Q(f , a): f is a flight on a;
¬∃w∀a∃f (P(w , f ) ∧ Q(f , a)) ≡ ∀w¬∀a∃f (P(w , f ) ∧ Q(f , a))
≡ ∀w∃a¬∃f (P(w , f ) ∧ Q(f , a))
≡ ∀w∃a∀f ¬(P(w , f ) ∧ Q(f , a))
≡ ∀w∃a∀f (¬P(w , f ) ∨ ¬Q(f , a))
“For every woman there is an airline such that for all flights, this womanhas not taken that flight or that flight is not on this airline.”
MING GAO (DaSE@ECNU) Discrete Mathematics and Its Applications Sep. 19, 2017 27 / 28