Sei sulla pagina 1di 13

CMPT 260 Introduction

Why prove it if its true, but is it true?


Every odd number greater than 1 can be expressed as a sum of a
power of 2 and a prime number
3 = 20 + 2
5 = 21 + 3
7 = 22 + 3
9 = 22 + 5

51 = 25 + 19

125 = 26 + 19
127 = ?

CMPT 260
Why prove it if its true, but is it true?
Begin with a positive integer, If the number is odd multiply by
three and add 1, if the number is even divide by 2.You will
eventually end up with a 1.

ex. 12,6,3,10,5,16,8,4,2,1

CMPT 260
Sets
A Set is a collection of elements
S = 1,2,3 = 3,2,1 = 3,3,2,1
- unordered, elements the same even if listed more than once
2 S - 2 is an element of S

Some sets
- R reals, Z integers, Q rationals - Z+ positive integers

Predicate | ()
|2< 9
CMPT 260
Sets
Subset
Proper subset
How many subsets are there are of S = , , , ?
Is ?
Is {} ?
Is ?
Is ?
= , , , , ,
How many elements are there is ? How many subsets?

CMPT 260
Cartesian Product
= ,

ie. = , = 4,5,6
= , 4 , 5 , 6 , 4 , 5 , 6
= { , , , , , , , }

= ?

CMPT 260
Relations
Let and be sets. A relation from to is a subset of
.
Given , in , is related to , (ie ) iff , is in
.
is the domain of , is the co-domain of .

ie. = , = 4,5,6
= , 4 , 5 , 6 , 4 , 5 , 6
from A to B, = , 4 , 4 , 6 , aR4 but not aR5
from to
= 4,5 , 4,6 , 5,6 is <

CMPT 260
Arrow Diagram of a Relation

= , , , = ,

a d
b
c e

CMPT 260
Functions
A Function from a set A to a set B is a relation with
domain A and co-domain B such that
1. For every element in A, there is an element in B such
that , F and
2. For all x in A and y and z in B if , F and , F
and then = .

a d
b
b
c e
CMPT 260
A Function?

CMPT 260
Functions
= ()
Equality
= , = ()}
= , = ()}

equals , = iff = for all in

CMPT 260
Examples
Hitting Set
Given a set of subsets of a finite set , and + with
. Is there a subset with such that
contains at least one element from each subset in ?
Subset Sum
Given a finite set , a function () from to + and a
positive integer , is there a subset such that the sum
of the () for all the elements in is exactly .

CMPT 260
Examples
Knapsack
Given a finite set , two functions and from to + , and
positive integers and , is there a subset such that
and such that () ?

CMPT 260

Potrebbero piacerti anche