Oct 7, 2003© Vadim Bulitko : CMPUT 272, Fall 2003, UofA1 CMPUT 272 Formal Systems Logic in CS I. E....
-
date post
19-Dec-2015 -
Category
Documents
-
view
217 -
download
1
Transcript of Oct 7, 2003© Vadim Bulitko : CMPUT 272, Fall 2003, UofA1 CMPUT 272 Formal Systems Logic in CS I. E....
Oct 7, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 1
CMPUT 272CMPUT 272Formal Systems Logic in Formal Systems Logic in
CSCS
CMPUT 272CMPUT 272Formal Systems Logic in Formal Systems Logic in
CSCS
I. E. LeonardUniversity of Alberta
http://www.cs.ualberta.ca/~isaac/cmput272/f03
Oct 7, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 2
Quiz I (October 9Quiz I (October 9thth))Quiz I (October 9Quiz I (October 9thth))
Coverage:Everything up to and including October 7th
lecture:textbook lectures seminars
Focus on the overlapping part:textbook lectures
Format:Problems similar in format to the assignments50 minutes in-classOpen book, notes, etc.Calculators are allowedNo team-work of ANY kind
Oct 7, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 3
ABOUT QUIZ 1ABOUT QUIZ 1ABOUT QUIZ 1ABOUT QUIZ 1
Exams were around the corner. During a lecture in
mathematical analysis the students questioned the professor about the contents
of the forthcoming paper.
“It will contain some interesting problems,” he said. “Right now faculty members are busy working on one of them. If we solve it,
it will be included in the examination paper.”
Mathematics and Informatics Quarterly, Volume 6, No. 1, 1996
Oct 7, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 4
Oct 7, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 5
Oct 7, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 6
Oct 7, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 7
Oct 7, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 8
Oct 7, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 9
Oct 7, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 10
Oct 7, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 11
Oct 7, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 12
Oct 7, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 13
Oct 7, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 14
TodayTodayTodayToday
Binary relationsEquivalence classesFloor & ceilingProof by contradictionand contraposition
Infinitude of primes
Irrationality of sqrt(p)
Oct 7, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 15
Binary RelationsBinary RelationsBinary RelationsBinary Relations A binary relation R from a set A to a set B is
a subset of the Cartesian Product AB, that is,
a set of ordered pairs (a,b) with aA and b BA binary relation R on a set A is a subset of the Cartesian product AA, that is, ordered pairs of the form (a,b) where a A and b A
Instead of (x,y) R AAWe use the shorthand notation: x R y
Examples:3 < 4Angela likes Belinda
Oct 7, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 16
PropertiesPropertiesPropertiesProperties
Reflexivity
Irreflexivity
Symmetry
Asymmetry
Anti-symmetry
Transitivity
Oct 7, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 17
QuestionsQuestionsQuestionsQuestions
Oct 7, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 18
Equivalence RelationEquivalence RelationEquivalence RelationEquivalence Relation
A relation is an equivalence relation iffit is reflexive, symmetric, and transitive
Examples:= on numbers, sets, etc.
mod n on integers
“logic equivalence” on formulae
Counter examples:<
Oct 7, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 19
Congruence RelationCongruence RelationCongruence RelationCongruence Relation
Any two integers a,b are congruent modulo n iff remainder(a,n) = remainder(b,n)Alternatively: a,b are congruent modulo n iff n divides a - b
Notation a b (mod n)Examples:
14 21 (mod 7)
15 22 (mod 7)
NOT 14 15 (mod 7)
6 0 (mod 2)
Oct 7, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 20
Congruence & Congruence & EquivalenceEquivalence
Congruence & Congruence & EquivalenceEquivalence
Theorem. For any integer n > 0 (mod n) is an equivalence relation
Properties to prove:Reflexive: for any a [a a (mod n)]Symmetric: for any a,b [a b (mod n) b a (mod n)]Transitive: for any a,b,c [a b (mod n) & b c (mod n)
a c (mod n)]
Oct 7, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 21
Equivalence ClassesEquivalence ClassesEquivalence ClassesEquivalence ClassesSuppose Ris an equivalence relation on AThen we can define subsets of A in this way:
[x] = {aA | a R x}, xA (a representative of the class)
Example:A=N
R is (mod 2)
[0] = {nN | n 0 (mod 2)} even numbers
[1] = {nN | n 1 (mod 2)} odd numbers
Question: how many equivalence classes does (mod 7) have?
Oct 7, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 22
QuestionsQuestionsQuestionsQuestions
Oct 7, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 23
PartitioningPartitioningPartitioningPartitioning
A set A is partitioned into sets {Ai} iff
The union of all Ai equals to A
Sets Ai are disjoint (i.e., don’t intersect)
Examples:{a,b,c} = {a,b} {c}N={0,1,…,9} {10,…,19}…N= [0] [1]
Oct 7, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 24
Equivalence Classes & Equivalence Classes & PartitioningPartitioning
Equivalence Classes & Equivalence Classes & PartitioningPartitioning
The last example demonstrated that
(mod 2) with its two equivalence classes [0] and [1] partitioned N
Will it always be the case?
In other words: are equivalence classes always going to form a partition of the set?
Oct 7, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 25
Theorem 1Theorem 1Theorem 1Theorem 1
For any set A and any equivalence relation R defined on it, the equivalence classes induced by R form a partition of A
Example:N= [0] [1] … [n-1]
with respect to (mod n)
Oct 7, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 26
Theorem 2: ConverseTheorem 2: ConverseTheorem 2: ConverseTheorem 2: Converse
For any set A and any partition {Ai} of A the binary relation R defined by a R b iff a,bA & i st a,bAi}is an equivalence relation on A
Proof structure:Show that R is reflexiveShow that R is symmetricShow that R is transitive
Oct 7, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 27
QuestionsQuestionsQuestionsQuestions
Oct 7, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 28
Floor & CeilingFloor & CeilingFloor & CeilingFloor & Ceiling
DefinitionsDifferent from the textbook’sfloor(x) = max{nZ st nx}, that is
the greatest integer less than or equal to xceiling(x) = min{nZ st nx}, that is
the smallest integer greater than or equal to x
Examplesfloor(5.75) = 5floor(-5.75) = -6ceiling(5.75) = 6ceiling(-5.75) = -5
xx ceiling(x)ceiling(x)floor(x)floor(x)
Oct 7, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 29
Equivalence to text’s defs and Equivalence to text’s defs and moremore
Equivalence to text’s defs and Equivalence to text’s defs and moremore
TheoremFor any xR\Z, floor(x) and ceiling(x) are defined, unique, and ceiling(x)=floor(x)+1
ProofPart 1: existencePart 2: uniquenessPart 3: relationship
CorollaryxR [floor(x) x < floor(x)+1]xR [ceiling(x)-1 < x ceiling(x)]
Oct 7, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 30
Lemmata Galore…Lemmata Galore…Lemmata Galore…Lemmata Galore…
mZ floor(m)=ceiling(m)=m
x,yR ceiling(x+y)ceiling(x)+ceiling(y)
xR mZ floor(x+m)=floor(x)+m
nZ floor(n/2)=n/2 iff n is even and floor(n/2)=(n-1)/2 iff n is odd
Oct 7, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 31
QuestionsQuestionsQuestionsQuestions
Oct 7, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 32
Types of ProofsTypes of ProofsTypes of ProofsTypes of Proofs
Many interesting statements are of the type:
n S(n)
Two primary proof methods:Direct
Take an arbitrary n, prove S(n), generalizeIf S(n) P(n)Q(n)
Then can prove ~Q(n)~P(n) instead
IndirectShow that n ~S(n) would lead to a contradiction
Oct 7, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 33
Contraposition & Contraposition & ContradictionContradiction
Contraposition & Contraposition & ContradictionContradiction
Suppose the statement to prove is:n [ P(n)Q(n) ]
Direct proof by contraposition:Take an arbitrary nShow that if ~Q(n) holds for that n then ~P(n) holds
Indirect proof (by contradiction):Assume P(n) and ~Q(n) hold for some nShow ~P(n)
Contradiction : cannot have P(n) and ~P(n)
Oct 7, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 34
IllustrationIllustrationIllustrationIllustration
If n2 is even then n is evenn [ P(n)Q(n) ]
Direct proof by contraposition:Assume ~Q(n) : n is not evenn is oddThen n=2k+1n2=4k2+4k+1n2 is odd : n2 is not even : ~P(n)
Oct 7, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 35
IllustrationIllustrationIllustrationIllustration
If n2 is even then n is evenn [ P(n)Q(n) ]
Indirect proof (by contradiction):Assume P(n) and ~Q(n)n2 is evenn is not even : n is oddThen n=2k+1n2=4k2+4k+1n2 is odd : n2 is even : contradiction
Oct 7, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 36
The third proofThe third proofThe third proofThe third proof
Theorem: n2 is even n is evenHow about a direct proof without contraposition?
ProofAssume n2 is even2 | n2
p|ab p|a v p|b (Euclid’s 1st theorem)2|n v 2|nThen n is even
Oct 7, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 37
QuestionsQuestionsQuestionsQuestions
Oct 7, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 38
Infinitude of PrimesInfinitude of PrimesInfinitude of PrimesInfinitude of Primes
There is no greatest prime:n m [ prime(n) m>n & prime(m) ]
Theorem 3.7.4 in the book
Will prove three lemmas first…
Oct 7, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 39
Lemma 0Lemma 0Lemma 0Lemma 0
If a|n and a|n+1 then a=1 v a=-1
Proofdirecta|n n=kaa|n+1 n+1=jaa(j-k)=1a=+1 v a=-1 (proved before)
Oct 7, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 40
Lemma 1Lemma 1Lemma 1Lemma 1
For any integer a and any prime p if p | a then ~(p | a+1)
ProofindirectSuppose such prime p existsp|a and p|a+1Then by Lemma 0: p=+1 or p=-1p cannot be primecontradiction
Oct 7, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 41
Lemma 2Lemma 2Lemma 2Lemma 2
A natural number n>1 is not prime iff there is a prime p<n such that p|n
Proof (direct):
If n is not prime then it has non-trivial divisors (proved before)Then one of them has a prime factor p (proved before)
Know that p<n and p|nThen p is a non-trivial factor of nThus n is not prime
Oct 7, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 42
Proof: Infinitude of Proof: Infinitude of PrimesPrimes
Proof: Infinitude of Proof: Infinitude of PrimesPrimes
Indirect (i.e., by contradiction)Suppose notThen
n m [ prime(n) & (mn v ~prime(m)) ] (*)
Thus, denote the only primes as p1, …, pk=n
Then consider m=p1 * …* pk + 1m>pi
m>n=pk
Is prime(m)?None of the primes pi divides it (by lemma 2)But there are no other prime numbers (by supposition)Thus, m is a prime (by lemma 1)This contradicts (*)
Oct 7, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 43
QuestionsQuestionsQuestionsQuestions
Oct 7, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 44
LemmaLemmaLemmaLemma
If qQ then there exist n,mZ such that q=n/m and gcd(n,m)=1Proof
Suppose we have n/m=q and gcd(n,m)>1Then compute n’, m’ :
n’=n/gcd(n,m)m’=m/gcd(n,m)
q=n’/m’ and n’,m’ are less than n and mEither gcd(n’,m’)=1 : then doneOr gcd(n’,m’)>1 : then repeat the process againMust terminate since n’ and m’ are decreasing
Oct 7, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 45
Another proof ?Another proof ?Another proof ?Another proof ?
How about another constructive proof?
Hint:Fundamental theorem of arithmetic
Oct 7, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 46
Irrationality of Irrationality of sqrt(2)sqrt(2)Irrationality of Irrationality of sqrt(2)sqrt(2)Define sqrt(x)=y such that yR, y*y=xLet’s prove that sqrt(2) is irrationalProof
Indirect (by contradiction)Suppose not: sqrt(2)=n/m and gcd(n,m)=1Then 2=n2/m2, 2m2=n2
n2 is even n is even (proved earlier)Then 2m2=4k2
Then m2 is even and so m is evenThus, gcd(n,m) is at least 2Contradiction
Oct 7, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 47
QuestionsQuestionsQuestionsQuestions
Oct 7, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 48
Irrationality of Irrationality of sqrt(p)sqrt(p)Irrationality of Irrationality of sqrt(p)sqrt(p)
Claim: for any prime p, sqrt(p) is irrational
How do we generalize the previous proof for this?
Oct 7, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 49
QuestionsQuestionsQuestionsQuestions