p q

advertisement
The Foundations: Logic and Proofs
1.1 Propositional Logic
• Introduction
• A proposition is a declarative sentence that is
either true or false, but not both.
• Example 1:
1. Washington DC is the capital of the United State.
2. Toronto is the capital of Canada.
3. 1+1=2
4. 2+2=4
• Example 2.
1. What time is it?
2. Read this carefully.
3. x+1=2
4. x+y=z
• We use letters to denote propositional
variables. The truth table of a proposition is
true, denoted by T, if it is a true proposition
and false, denoted by F, if it is a false
proposition.
• The area of logic that deals with propositions
is called propositional calculus or
propositional logic.
• New propositions, called compound
propositions, are formed from existing
propositions using logical operators.
• Let p be a proposition. The negation of p,
denoted by p (also denoted by p ). Is the
statement “It is not that 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.
p
p
T
F
F
T
• The negation of a proposition can also be
considered the result of the operation of the
negation operator on a proposition. We will
now introduce the logical operators that are
used to form new propositions from two or
more propositions. These logical operators
are called connectives.
• 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.
p
q
pq
T
T
T
T
F
F
F
T
F
F
F
F
• Let p and q be propositions. The disjunction
of p and q, denoted by pq, is the proposition
“p or q”. The disjunction p  q is false when
both p and q are false and is true otherwise.
p
q
pvq
T
T
T
T
F
T
F
T
T
F
F
F
• Example: Find the conjunction and the
disjunction of the propositions p and q where
p is the proposition “Today is Friday” and q is
the proposition “It is raining today”.
• 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.
p
q
pq
T
T
F
T
F
T
F
T
T
F
F
F
Conditional Statements
• Let p and q be propositions. The conditional
statement pq is the proposition “if p, then
q”. The conditional statement pq is false
when p is true and q is false, and true
otherwise.
• In the conditional statement pq, p is called
hypothesis (or antecedent or premise) and q is
called conclusion (or consequence).
p
q
T
T
T
T
F
F
F
T
T
F
F
T
pq
• A conditional statement is also called an
implication.
pq
•
•
•
•
•
•
•
•
•
•
•
•
•
“if p, then q”
“if p, q”
“p is sufficient for q”
“q if p”
“q when p”
“a necessary condition for p is q”
“q unless p”
“p implies q”
“p only if q”
“a sufficient condition for q is p”
“q whenever p”
“q is necessary for p”
“q follows from p”
• Example: Let p be the statement “Maria
learns discrete mathematics” and q the
statement “Maria find a good job.” Express
the statement pq.
• If Maria learns discrete mathematics, then she
will find a good job.
• pq.
• The proposition qp is called the converse of
pq.
• The contrapositive of pq is the proposition
q  p.
• The proposition p  q is called the inverse
of pq.
• 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.
p
• Biconditional statements are
also qcalled pq
biT
T
T
implications.
T
F
F
F
T
F
F
F
T
• “p is necessary and sufficient condition for q”
• “if p then q, and conversely”
• “p iff q”
• pq has the same truth value as
(pq) (qp)
Truth Tables of Compounds
Propositions
• Construct the truth table of the compound
proposition (pq) (pq).
P
q
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
pq
(pq) (p  q)
Precedence of logical operators
Operator
Precedence

1

2

3

4

5
•Applications
Translating English Sentences
• You can access the Internet from campus only
if you are a computer science major or you are
not a freshman.
• A: You can access the Internet from campus.
• C: you are a computer science major .
• F: you are a freshman.
• A(CF)
System Specifications
• Example: The automated reply cannot be
send when the file system is full.
• p: the automated reply can be send
• q: the file system is full
• qp
• System specifications should be consistent,
that is, they should not contain conflicting
requirements that could be used to derived a
contradiction.
• Example: Determine whether the system specifications
are consistent:
1. The diagnosis message is stored in the buffer or it is
retransmitted.
2. The diagnosis message is not stored in the buffer.
3. If the diagnosis message is stored in the buffer, then it
is retransmitted.
 p: the diagnosis message is stored.
 q: the diagnosis message is retransmitted.
 pq, p, pq
 p is false and q is true
• Example: Can we add one more specification:
The diagnosis message is not retransmitted.
• No
Boolean Searches
• Web page searching
Logic Puzzles
• Smullyan posed many puzzles about an island
that has two kinds of inhabitants, knights,
who always tell the truth, and the opposites,
knaves, who always lie. You encounter two
people A and B. What are A and B if A says “B
is a knight” and B says “The two of us are
opposite types”?
• Both A and B are knaves.
• Try more?
Logic and Bit Operations
Truth value
Bit
T
1
F
0
x
y
xy
xy
xy
0
0
0
0
0
0
1
1
0
1
1
0
1
0
1
1
1
1
1
0
• Example: Find the bitwise OR, bitwise AND,
and bitwise XOR of the bit strings
01 1011 0110 and 11 0001 1101
1.2 Propositional Equivalences
• A compound proposition that is always true is
called a tautology. A compound proposition
that is always false is called a contradiction. A
compound proposition that is neither a
tautology nor a contradiction is called a
contingency.
• Example: pp is a tautology and pp is a
contradiction.
• The compound propositions p and q are called
logical equivalent if pq is a tautology. The
notation pq denotes that p and q are logical
equivalent.
• The symbol  is sometimes used instead of 
to denote logical equivalence.
• Example: Show that (pq) and pq are
logical equivalent
P
q pq
(pq)
p
q
pq
T
T T
F
F
F
F
T
F T
F
F
T
F
F
T T
F
T
F
F
F
F
T
T
T
T
F
• Show that pq and pq are logical
equivalent.
• Show that p(qr) and (pq)(pr) are logical
equivalent.
Some important equivalences
• Identity laws
pTp
pFp
• Domination laws
p  TT
p  FF
• Identity laws
ppp
ppp
• Double negation law
• Commutative laws
pq qp
pq qp
(p)p
• Associative laws
p(qr) p(qr)
p (qr) p (q  r)
• Distributive laws
p(qr) (pq)(pr)
p(qr) (pq)(pr)
• De Morgan’s laws
(pq) pq
(p q) pq
• Absorption laws
p(p  q) p
p (pq) p
• Negation laws
pp T
p p F
1.3 Predicates and Qualifiers
• Predicate
• Example: Let P(x) denote the statement “x>3”.
What are the truth values of P(4) and P(2)?
• Example: Let A(x) denote the statement
“Computer x is under attack by and intruder.”
Suppose that of the computers on campus,
only CS2 and MATH1 are currently under
attack by intruders. What are the truth
values of A(CS1), A(CS2), and A(MATH1)?
• A statement of the form P(x1,x2,…,xn) is the
value of the propositional function P at the ntuple (x1,x2,…,xn), and P is also called a n-place
predicate or a n-ary predicate.
• Propositional functions occur in computer
programs. For example: “if x>0 then x:=x+1”.
P(x) is “x>0”.
Quantifiers
• Many mathematical statements assert that a
property is true for all values of a variable in a
particular domain, caller the domain of
discourse (or the universe of discourse), often
just referred to as the domain.
• The universal quantification of P(x) is the
statement “P(x) for all values of x in the domain”.
• The notation x P(x) denote the universal
quantification of P(x).
• Here  is called universal quantifier.
• We read x P(x) as “for all x P(x)” or “for every x
P(x).”
• An element for which P(x) is false is called a
counterexample of x P(x).
• Example: Let P(x) be the statement “x+1>x.”
What is the truth value of the quantification x
P(x), where the domain consists of all real
numbers.
• Example: Let Q(x) be the statement “x<2.” What
is the truth value of the quantification x Q(x),
where the domain consists of all real numbers.
• Example: Suppose that P(x) is “ x 2 >0.” Show that
P(x) is false by finding an counterexample.
• The existential quantification of P(x) is the
proposition “there exists an element x in the
domain such that P(x)”. We use the notation
x P(x) for the existential quantifier of P(x).
• Here  is called existential quantifier.
• The existential quantifier x P(x) is read as
“there is an x such that P(x),” “There is at least
one x such that P(x)”. Or “For some x P(x).
• Example: Let P(x) denote the statement “x>3”. What is
the truth value of the quantification x P(x), where the
domain consists of all real numbers?
• Example: Let Q(x) denote the statement “x=x+1”.
What is the truth value of the quantification x Q(x),
where the domain consists of all real numbers?
• Example: What is the truth value of x P(x), where P(x)
is the statement “ x 2 > 10” and the universe of
discourse consists of positive integer not exceeding 4?
Uniqueness quantifier
• The notation x P(x) [or 1x P(x)] states
“There exists a unique x such that P(x) is true.”
• Statements involving predicates and
quantifiers are logical equivalent if and only if
they have the same truth value no matter
which predicates are substituted into these
statements and which domain of discourse is
used for the variables in these propositional
functions. We use the notation ST to
indicate that two statements S and T involving
predicates and quantifiers are equivalent.
•
•
•
•
x (P(x) Q(x))x P(x)  x Q(x).
De Morgan’s Laws for Quantifiers
x P(x)x P(x).
x P(x)x P(x).
Applications
1.4 Nested Quantifiers
• Example: Assume that the domain for the
variables x,y, and z consists of all real nembers.
x y (x+y=y+x) (commutative law)
• x  y (x+y =0) (additive inverse)
• x y z (x+(y+z))=((x+y)+z) (associative law)
• Example: Translate into English the statement
xy ((x> 0) (y<0)(xy<0))
where the domain for both variables consists
of all real numbers.
The order of Quantifiers
Let the domain for x, y, and z are real numbers.
xy (x+y=0) (True)
 xy (x+y=0) (False)
x y (x+y=y+x)
y x (x+y=y+x)
 x  y z (x+y=z) (True)
z  x  y (x+y=z) (False)
Negating Nested Quantifiers
• Example: Express the negation of the
statement xy (xy=1) so that no negation
precedes a quantifier.
•  ( xy (xy=1))
• x y(xy1)
1.5 Rules of Inference
• An argument in propositional logic is a sequence of
proposition. All but the final proposition in the
argument are called premises and the final proposition
is called conclusion. An argument is valid if the truth of
all its premises implies that the conclusion is true.
• An argument form in propositional logic is a sequence
of compound propositions involving propositional
variables. An argument form is valid if no matter which
particular propositions are substituted for the
propositional variables in its premises, the conclusion
is true if the premises are all true.
• p pq addition rule
• Example. It is below freezing now.
Therefore, it is either below freezing or raining
now.
• pq p simplification
• Example. It is below freezing and rainng now.
Therefore, it is either below freezing.
• [q(p  q)]  p modus tollens
• [(p  q)  (q r)] (p  r) Hypothetical
syllogism
• [(p  q)   p ] q Disjunctive syllogism
• [(p ) (q)] (p  q) Conjunction
• [(p  q)  (p  r)] (q  r) Resolution
• x P(x)
P( c )
(Universal instantiation)
• P( c) for an arbitrary c
 x P(x)
(Universal generalization)
•  x P(x)
(Existential instantiation)
P( c) for some arbitrary c
• P( c) for some arbitrary c
 x P(x) )
(Existential generalization)
1.6 Introduction to Proofs
•
•
•
•
•
•
•
Some terminology
Theorem
Propositions
Axioms
Lemma
Corollary
conjecture
• Understand How Theorems are stated
Methods of Proving Theorems
• Direct proof
• Proof by contraposition
• Proof by contradiction
Mistakes in proofs
Direct Proofs
• Example. Given a direct proof of the theorem
“If n is an odd integer then n2 is odd.”
• Example: Given a direct proof that if m and n
are both perfect squares, then mn is also a
perfect square.
Proof by Contraposition
• Example: Prove that n is an integer and 3n+2
is odd, then n is odd.
• Example: Prove that if n=ab, where a and b
are positive integers, then an1/2 or bn1/2
Vacuous and trivial proofs
• Example: Show that the position P(0) is “If
n>1, then n2>n” and the domain consists of all
integers.
• Example: Let P(n) by “If a and b are positive
integers with ab, then anbn,” where the
domain consists of all integers. Show that P(0)
is true.
A little proof strategy
• Example: Proof that the sum of two rational
numbers is rational.
Proof. Let r=p/q with q0 and s=t/u with u0.
Then r+s=(pu+qt)/(qu).
• Example: Proof that if n is an integer and n2
is odd, then n is odd.
Proof by Contradiction
• Example: Show That at least four of any 22
days must fall on the same day of the week.
• Example: Prove that 2 is irrational.
• Example: Give a proof by contradiction of the
theorem “If 3n+2 is odd, then n is odd.”
Proofs of Equivalence
• Example: Proof the theorem “If n is a positive
integer, then n is odd if and only if n2 is odd.
• Example: Show that these statements about
integer n are equivalent
P1: n is even
P2: n-1 is odd
P3: n2 is even
Counterexamples
• Show that the statement “Every positive
integer is the sum of the squares of two
integers” is false.
3 is not the sum of the squares of two integers.
Mistakes in Proofs
1.7 Proof Methods and Strategy
• Exhaustive Proof
• Example: Prove that (n  1)2  3n if n is a
positive integer with n4.
• Example: Prove that the only consecutive
positive integers not exceeding 100 that are
perfect powers are 8 and 9.
Proof by Cases
• Example: Prove that n is an integer, then n 2 n.
• Example: Use the proof by cases to show that
|xy|=|x||y| where x and y are real numbers.
Leveraging Proof by Cases
• Example: Formulate a conjecture about
decimal digits that occur as the final digit of
the square of an integer and prove this result.
• Example: Show that there is no solutions in
integers x and y of x 2  3 y 2  8 .
Existence Proof
• Example: A constructive existence proof.
Show that there is a positive integer that can
be written as the sum of cubes of positive
integers in two ways.
1729  103  93  123  13
Non constructive Existence Proof
• Example: Show that there exist irrational
number x and y such that xy is rational.
• 21/2 is irrational
• x=y=21/2
• If xy is rational, done
• If xy is irrational, let X=xy.
• Then Xy =2 is rational
• Chomp is a game played by two player. In this
game, cookies are laid out on a rectangular
grid. The cookie in the top left is poisoned.
The two players take turns making moves; at
each move, a player is required to eat a
remaining cookie, together with all cookies to
the right and/or below it. The loser is the
player who has no cookie but to eat the
poisoned cookie. We ask whether one of the
two players has the winning strategy.
Uniqueness Proofs
• Example. Show that if a and b are real
numbers and a0, then there is a unique real
number r such that ar+b=0.
• Existence
• Uniqueness
Proof Strategies
• Forward and backward reasoning
• Example: Given two positive real numbers x
and y, prove that the arithmetic means is
greater than or equal to the geometric mean;
x y
i.e.,
 xy.
2
x y
 xy.
2
( x  y)2
 xy.
4
( x  y ) 2  4 xy.
x 2  2 xy  y 2  4 xy.
x 2  2 xy  y 2  0.
( x  y ) 2  0.
• Example: Suppose that two people play a
game taking turns moving one, two, or three
stones at a time from a pile that begins with
15 stones. The person who removes the last
stone wins the game. Show that the first
player win the game no matter what the
second player does.
Adapting Existing Proofs
• Example: Prove that 3 is irrational.
Looking for Counterexamples
• Example: The statement that “Every positive
integer is the sum of two squares of integers”
is not true by finding counterexamples. Yet, it
is proved that “Every positive integer is the
sum of three squares of integers”.
•
•
•
•
•
Exercise:
1.1 27(f)
1.2 28, 29
1.3 12, 31, 35
1.4 26, 27, 31
• Example: Can we tile the standard chessboard using
dominos?
• Example: Can we tile a board obtained by removing
one of the corner squares of a standard chess board?
• Example: Can we tile a board obtained by deleting the
upper left and the left lower corner squares of the
corner squares of a standard chess board?
• Example: Can we use straight triominoes to a standard
chess board?
• Example: Can we use straight triominoes to a standard
chess board with one of its four corners removed?
The Roles of Open Problems
• Fermat’s last theorem: The equation
xn  y n  z n
has no solutions in integers x, y, and z with xyz0
whenever n is an integer with n>2.
• The 3x+1 conjecture: Let T to be the
transformation that sends an even integer x to
x/2 and odd integer x to 3x+1. For any positive
integer x, when we repeatedly apply the
transformation T, we will eventually reach the
integer 1.
Download