lecture 07© vadim bulitko : cmput 272, winter 2004, uofa1 cmput 272 formal systems logic in cs...
TRANSCRIPT
Lecture 07 © Vadim Bulitko : CMPUT 272, Winter 2004, UofA 1
CMPUT 272CMPUT 272Formal Systems Logic in Formal Systems Logic in
CSCS
CMPUT 272CMPUT 272Formal Systems Logic in Formal Systems Logic in
CSCS
Vadim BulitkoUniversity of Alberta
http://www.cs.ualberta.ca/~bulitko/W04
Lecture 07 © Vadim Bulitko : CMPUT 272, Winter 2004, UofA 2
TodayTodayTodayToday
Chapter 3.1
Chapter 3.2
Chapter 3.3
All
imag
es
are
cop
yri
gh
ted
to t
heir
resp
ect
ive c
op
yri
gh
t h
old
ers
an
d r
ep
rod
uce
d h
ere
for
aca
dem
ic p
urp
ose
s u
nd
er
the c
on
dit
ion
of
“fair
usi
ng
”.
Lecture 07 © Vadim Bulitko : CMPUT 272, Winter 2004, UofA 3
NumbersNumbersNumbersNumbers
We will work with numbers for the next little whileR is the set of all real numbers
0, 1, -5.27, Pi, …
Q is the set of rational numbers0, 1, -5.27, …
Z is the set of integer numbers0, 1, -1, 2, …
N is the set of natural numbers0, 1, 2, …
Lecture 07 © Vadim Bulitko : CMPUT 272, Winter 2004, UofA 4
Odd / EvenOdd / EvenOdd / EvenOdd / Even
Define predicate even(n):n is an even integer iffExists an integer k such that n=2knZ [even(n) kZ [n=2k]]
Define predicate odd(n):n is an even integer iffExists an integer k such that n=2k+1nZ [odd(n) kZ [n=2k+1]]
Lecture 07 © Vadim Bulitko : CMPUT 272, Winter 2004, UofA 5
A theoremA theoremA theoremA theorem
“Every integer is even or odd. But not both”
nZ [(odd(n) v even(n)) & ~(odd(n) & even(n))]
Need some premises:Integer numbers are closed under +, *Trichotomy law: any number >0, =0, <0Well ordering principle: Every non-empty set of naturals contains its smallest element
Proof – recall how we introduced integers
Lecture 07 © Vadim Bulitko : CMPUT 272, Winter 2004, UofA 6
Lemma 1Lemma 1Lemma 1Lemma 1
Let’s prove an auxiliary statement first:
For any r,xR if 0<r,x<1 then rx<rr,xR [0<r,x<1 rx<r]
Proof:x<1r>0 rx<r
Lecture 07 © Vadim Bulitko : CMPUT 272, Winter 2004, UofA 7
Lemma 2Lemma 2Lemma 2Lemma 2
Let’s prove another auxiliary statement:There are no integers between 0 and 1~ ( nN [0<n<1] )
Proof:Suppose notThen nN [0<n<1]Consider set S={n, n2, n3, …}Every sS is integer and non-negative (i.e., natural)Therefore min(S)=sm S
Consider sm*n then: sm*nS and sm*n<sm (by Lemma 1)Thus, smmin(S) Contradiction
Lecture 07 © Vadim Bulitko : CMPUT 272, Winter 2004, UofA 8
Theorem (part 1)Theorem (part 1)Theorem (part 1)Theorem (part 1)
“Every integer is even or odd”nZ [ odd(n) v even(n) ]
Proof:Suppose not
Then nZ [~(odd(n) v even(n))]
Then let’s find the minimum m=2k such that n<mClearly, 2k-2<n<2kSubtract 2k from both sides: 0<n-2k+2<2Then n-2k+2 is : between 0,1 or between 1,2 or 1
Lecture 07 © Vadim Bulitko : CMPUT 272, Winter 2004, UofA 9
Theorem (part 2)Theorem (part 2)Theorem (part 2)Theorem (part 2)
“No integer is even and odd”~ nZ [ odd(n) & even(n) ]
Proof:Suppose not
Then nZ [odd(n) & even(n)]
By the definitions: n=2k and n=2m+1Thus, 2k=2m+1Subtract 2m from both sides: 2(k-m)=1Thus, k-m=½ not an integer
Lecture 07 © Vadim Bulitko : CMPUT 272, Winter 2004, UofA 10
Prime / CompositePrime / CompositePrime / CompositePrime / Composite
Define predicate prime(n):n is a prime number iffn>1 and for any its positive integer factors r and s one of them is 1nZ [prime(n) n>1 & r,sN [n=rs r=1 v s=1]]
Define predicate composite(n):n is a composite integer iffn is not prime and is greater than 1nZ [composite(n) n>1 & ~prime(n)]
Lecture 07 © Vadim Bulitko : CMPUT 272, Winter 2004, UofA 11
Existential StatementsExistential StatementsExistential StatementsExistential Statements
x P(x)Proofs:
ConstructiveConstruct an example of such x
Non-constructiveBy contradiction
Show that if such x does NOT exist than a contradiction can be derived
Lecture 07 © Vadim Bulitko : CMPUT 272, Winter 2004, UofA 12
ExampleExampleExampleExample
Prove that nN a,b prime(a) & prime(b) & (a+b=n)
Proof:n=210a=113b=97
// Piece of cake…
Lecture 07 © Vadim Bulitko : CMPUT 272, Winter 2004, UofA 13
Universal StatementsUniversal StatementsUniversal StatementsUniversal Statements
x P(x)x [Q(x) R(x)]
Proof techniques:ExhaustionBy contradiction
Assume the statement is not trueArrive at a contradiction
DirectGeneralizing from an arbitrary particular member
Mathematical induction (chapter 4)
Lecture 07 © Vadim Bulitko : CMPUT 272, Winter 2004, UofA 14
Example 1Example 1Example 1Example 1
Exhaustion:Any even number between 4 and 30 can be written as a sum of two primes:
4=2+26=3+38=3+5…30=11+19
Lecture 07 © Vadim Bulitko : CMPUT 272, Winter 2004, UofA 15
Problems?Problems?Problems?Problems?
Works for finite domains only
What if I want to prove that for any integer n the product of n and n+1 is even?
Can I exhaust all integer values of n?
Lecture 07 © Vadim Bulitko : CMPUT 272, Winter 2004, UofA 16
Example 2Example 2Example 2Example 2
Theorem: nZ [ even(n*(n+1)) ]Proof:
Consider a particular but arbitrary chosen integer n n is odd or evenCase 1: n is odd
Then n=2k+1, n+1=2k+2n(n+1) = (2k+1)(2k+2) = 2(2k+1)(k+1) = 2p for some integer pSo n(n+1) is even
Lecture 07 © Vadim Bulitko : CMPUT 272, Winter 2004, UofA 17
Example 2 (cont’d)Example 2 (cont’d)Example 2 (cont’d)Example 2 (cont’d)
Case 2: n is evenThen n=2k, n+1=2k+1n(n+1) = 2k(2k+1) = 2p
for some integer p
So n(n+1) is even
Done!
Lecture 07 © Vadim Bulitko : CMPUT 272, Winter 2004, UofA 18
FallacyFallacyFallacyFallacy
Generalizing from a particular but NOT arbitrarily chosen exampleI.e., using some additional properties of nExample:
“all odd numbers are prime”“Proof”:
Consider odd number 3It is primeThus for any odd n prime(n) holds
Such “proofs” can be given for correct statements as well!
Lecture 07 © Vadim Bulitko : CMPUT 272, Winter 2004, UofA 19
PreventionPreventionPreventionPrevention
Try to stay away from specific instances (e.g., 3)
Make sure that you are not using any additional properties of n considered
Challenge your proofTry to play the devil’s advocate and find holes in it…
Lecture 07 © Vadim Bulitko : CMPUT 272, Winter 2004, UofA 20
Other Common Other Common MistakesMistakes
Other Common Other Common MistakesMistakes
Pages 120-121 in the book
Using the same letter to mean different things
Jumping to a conclusionInsufficient justification
Begging the questionassuming the claim first
Lecture 07 © Vadim Bulitko : CMPUT 272, Winter 2004, UofA 21
Rational NumbersRational NumbersRational NumbersRational Numbers
A real number is rational iff it can be represented as a ratio/quotient/fraction of integers a and b (b0)
rR [rQ a,bZ [r=a/b & b0]]
Notes:a is numeratorb is denominatorAny rational number can be represented in infinitely many waysThe fractional part of any rational number written in any natural radix has a period in it
Lecture 07 © Vadim Bulitko : CMPUT 272, Winter 2004, UofA 22
Rational or not?Rational or not?Rational or not?Rational or not?
-12-12/1
3.14593+1459/10000
0.56895689568956895689…5689/9999
1+1/2+1/4+1/8+…2
00/1
Lecture 07 © Vadim Bulitko : CMPUT 272, Winter 2004, UofA 23
Theorem 1Theorem 1Theorem 1Theorem 1
Any number with a periodic fractional part in a natural radix representation is rationalProof:
Constructive, radix=10, no whole part:x=0.n1…nmn1…nm…
x=0.(n1…nm)
x*10m-x=n1…nm
x=n1…nm/(10m-1)
Lecture 07 © Vadim Bulitko : CMPUT 272, Winter 2004, UofA 24
Theorem 2Theorem 2Theorem 2Theorem 2
Any geometric series:S=q0+q1+q2+q3+…where -1<q<1evaluates to S=1/(1-q)
ProofProof idea (informally)More formal proofDefinitions of limits and partial sums
Lecture 07 © Vadim Bulitko : CMPUT 272, Winter 2004, UofA 25
Z Z Q QZ Z Q Q
Every integer is a rational number
Proof : set the denominator to 1Book : page 127
Lecture 07 © Vadim Bulitko : CMPUT 272, Winter 2004, UofA 26
QQQQ
The set of rational numbers is closed with respect to arithmetic operations +, -, *, /
Partial proofs : textbook pages 121-131
Formal proof
Lecture 07 © Vadim Bulitko : CMPUT 272, Winter 2004, UofA 27
Irrational NumbersIrrational NumbersIrrational NumbersIrrational Numbers
So far all the examples were of rational numbers
How about some irrationals?esqrt(2)