slide 2 1
TRANSCRIPT
-
7/30/2019 Slide 2 1
1/3
( ,
Mathematics for Computer Science
MIT 6.042J/18.062J
Predicates & Quantifiers
Induction
opyright Albert R. Meyer, 2002. L2-1.1
Predicates
Predicates are
Propositions with variables
Example:
P(x,y) ::= x + 2 =y
is defined to be
Copyright Albert R. Meyer, 2002. L2-1.2
Predicates
2P x y) ::=x + = yx = 1 andy = 3: P(1,3) is true
x = 1 andy = 4: P(1,4) is false
P(1,4) is true
opyright Albert R. Meyer, 2002. L2-1.3
Quantifiers
x ForALLx
y There EXISTS somey
Copyright Albert R. Meyer, 2002. L2-1.4
+
Quantifiers
x,y range overDomain of Discourse
x y x
-
7/30/2019 Slide 2 1
2/3
r r
r r
Problems
Proof by InductionClass Problems 1& 2
opyright Albert R. Meyer, 2002. L2-1.7 Copyright Albert R. Meyer, 2002. L2-1.8
An Example of Induction
Suppose we have a property (say color) of
the natural numbers:
0, 1, 2, 3, 4, 5,
Showing thatzero is red, and that
thesuccessor of any red number is red,
proves that allnumbers are red!
opyright Albert R. Meyer, 2002. L2-1.9
The Induction Rule
0 and (from n to n+1)
proves 0, 1, 2, 3,.
R(0),n [R(n) R(n +1)]m ( ) R m
Copyright Albert R. Meyer, 2002. L2-1.10
Proof by Induction
Statements in green form a template for inductive
proofs:
Proof: (by induction on n)
The induction hypothesis:
rn+1
1P( ) ::= 1+ + 2 ++rn =
r1n
An Aside: Ellipses
Ellipses () mean that the reader is supposed
to infera pattern.
This can lead to confusion about what isbeing stated.
Here summation notation gives moreprecision, for example:
n
1+ + 2 ++rn = rii=0
Copyright Albert R. Meyer, 2002. L2-1.12opyright Albert R. Meyer, 2002. L2-1.11
-
7/30/2019 Slide 2 1
3/3
r r
r r
r r
Example Induction Proof An Example Proof
Base Case (n = 0):+ Revised Induction Hypothesis:
2 ++r0 ? r0 1
11+ + =
r1
P n) ::= 1 1+ + 2
++rn
=r
n
r
+1
1
1
1 ( rr1= =1
Wait: divide by zerobug!r1
This is only true forr1opyright Albert R. Meyer, 2002. L2-1.13 Copyright Albert R. Meyer, 2002. L2-1.14
An Example Proof An Example Proof
HaveP(n) by assumption:Induction Step: AssumeP(n) forn 0 to
1+ + 2 ++rn =rn+1 1proveP(n + 1): r1
n+r 1 1+r+r2 ++rn+1 =r( 1)+1 1 Adding rn+1 to both sides: n+1
r1 1+ + rn +rn+1 = r 1 +rn+1r1
1rn+1 + rn+1(r1)=r1
opyright Albert R. Meyer, 2002. L2-1.15 Copyright Albert R. Meyer, 2002. L2-1.16
L2-1.17opyright Albert R. Meyer, 2002.
An Example Proof
Continued
Which is justP(n+1)
QED.
1 11
( 1) 1
11
1
1
1
n nn
n
r r rr
r
r
r
+ ++
+ +
+ ++ + + =
=
1nn rr +
Problems
Class Problem 3
Copyright Albert R. Meyer, 2002. L2-1.18