0% found this document useful (0 votes)
39 views

4.set Theory

This document provides an introduction to set theory and functions. It defines what sets are, provides examples of common sets like natural numbers and integers, and covers basic set concepts like unions, intersections, subsets, and complements. It also defines what a function is, including domain, range, partial vs total functions, and one-to-one and onto functions. The goal is to introduce the key concepts in a "naive" or basic way sufficient for an introductory computer science course on the topic.

Uploaded by

aksrathore
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views

4.set Theory

This document provides an introduction to set theory and functions. It defines what sets are, provides examples of common sets like natural numbers and integers, and covers basic set concepts like unions, intersections, subsets, and complements. It also defines what a function is, including domain, range, partial vs total functions, and one-to-one and onto functions. The goal is to introduce the key concepts in a "naive" or basic way sufficient for an introductory computer science course on the topic.

Uploaded by

aksrathore
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

2 SET THEORY

Now let us move on to set theory, starting with a simple, but ultimately problematic, version of set theory called naive set theory. For CS 360, it is enough that you understand just this version of set theory.

2.1 DEFINITION AND EXAMPLES OF SETS


What is a set? That turns out to be a question with a more complicated answer than you might think. One way to define sets is to treat the notion as basically being self-evident, along the lines of this definition: A set is an unordered collection of distinct objects. Sometimes people call set theory based on this sort of definition naive set theory, because it turns out to be naive to think that the notion of a set really is so simple and self-evident. However, although there are serious problems with this approach that strongly motivate basing the theory on amore firmmathematical foundation, youwill not run into problems in this course by thinking about sets in the naive manner. An example of a set is this one: {a, b, c} It has three members or elements: a, b, and c. This set is no different from {b, a, c} because the ordering of the elements in a set does not matter. It is also no different from {a, a, b, c} because we only care about distinct objects. Another way of thinking about this is that the only concept that really matters for a set is membership: if A is a set and x is an object, then either x is an element of A or it isnt. If x is an element of A, then we write x A and if not we write x 6 A. There should always be a definite answer to the question of whether or not some object is contained in a given set. If that is not the case, then the set is not well-defined and you wont be able to reason about the set using set theory. In other words, the set is really not a set at all. Sets can have a finite number of elements or an infinite number. For example, here are some important infinite sets whose elements are numbers: 1. The natural numbers: N = {0, 1, 2, 3, . . .}. (Some people choose not to include 0 in this set. This is nothing more than a definition, so neither way is right or wrong.) 2. The integers: Z = {. . . ,2,1, 0, 1, 2, . . .}. 3. The rational numbers: Q= n x:x=

n m for integers n,m with m 6= 0 o . 4. The real numbers R. (I will not define these formally because it would be a complicated digression. I assume you have some intuition about real numbers, which is enough for now.) In the first and second examples, we use some dots like this: . . .. They mean: continue the pattern in the obvious way. In the third example, we use this sort of notation: _ : where the boxes are replaced by something. Sometimes people use a vertical line instead of a colon :. You can think of the second box as representing some general conditions, and when those conditions are satisfied the first box represents the actual elements of the set. For example, the set of even natural numbers could be written like this: {n N : n is divisible by 2} , or like this: {2n : n N} . The notations above are useful for defining both finite and infinite sets, especially where it is not possible or practical to write down all of the elements.

2.2 BASIC CONCEPTS


At this point let us go through some very basic concepts about sets that I assume you know. The purpose of doing this is (i) to make certain you know or remember these things, and (ii) to make clear the specific notation we will use in the course. The empty set is the set containing no elements at all. We write it like this: . For every possible object x we have x 6 . The union of two sets A and B is the set that contains exactly those objects that are contained in either A or B (or both). This set is denoted A B. The intersection of two sets A and B is the set that contains exactly those objects that are contained in both A and B. This set is denoted A B. We say that a set A is a subset of another set B if every element of A is also contained in B. We write A B in this case, and we write A 6 B when it is not the case. By the way, if you want to prove A B in some specific situation, you would often start by writing this: Let x A. Here x is some arbitrary element of A that you dont place any

restrictions on. From there, based on the definitions of A and B, you argue that x B. If you can do this, and all along the way no restrictions have been placed on x beyond the assumption that it is an element of A, then youve proved A B. We can write A( B when A B and B 6 A are both true. Some people use the symbol to mean ( while others use it to mean . I will simply not use the symbol in order to avoid confusion. Two sets are equal when they have exactly the same elements, and in this case we write A = B. When you want to prove this in some situation, it usually means you have to do two things: first prove A B and then prove B A. If A and B are sets, then the set difference A\B is the set of all elements in A that are not in B: A\B = {x A : x 6 B} . Some people write A B to mean the same thing. Sometimes we work in a situation in which all sets of interest are subsets of some fixed set U called the universe. For example, our universe might be U = N when we are talking about properties of natural numbers. In CS 360, it will be common to work in a universe consisting of all possible strings over some set of symbols. When some universe U is specified, and we have a set A U, we define the complement of A to be the set A = U\A. When A and B are subsets of some universe U, we have A B = A B and A B = A B. These are called De Morgans Laws. For every set A, we define the power set of A to be the set P(A) containing all subsets of A as its elements: P(A) = {B : B A} . For example, if A = {1, 2, 3} then P(A) = {, {1}, {2}, {3}, {1, 2}, {1, 3}, {2, 3}, {1, 2, 3}}. The Cartesian product of a set A with a set B is formed by pairing elements from the two sets. Specifically, we define A B = {(x, y) : x A and y B} . The notation (x, y) denotes an ordered pair, meaning that the order matters. More generally we can take Cartesian products of any finite number of sets: if A1, . . . , An are sets for some integer n 2, then A1 A2 An = {(x1, . . . , xn) : xi Ai for all i = 1, . . . , n} .

2.3 FUNCTIONS
A function f from a set A to a set B is, intuitively speaking, a way of transforming elements of A

into elements of B. For example, we can define a function f from N toN that transforms n to 5n2. We would normally express this function as follows: f (n) = 5n2. If we just want to express that, say, g is a function from A to B for certain sets A and B, we write g : A B. When you see this, you cannot tell very much about g, other than that it transforms elements of A into elements of B. Formally speaking, a function f from A to B is defined as a subset of f A B with the property that if (a, b) f and (a, c) f , then b = c. If (a, b) f , then we use the more familiar notation f (a) to mean b. This is sensible because there cannot be more than one such element b. Notice that according to the formal definition of a function, it is possible that a function f : A B could be such that some element a A has no corresponding element b B satisfying (a, b) f . This means that f is not defined at a, and in this case we write this: f (a) A function like this is called a partial function. If f (a) is defined for all a A, then f is called a total function. You are probably used to working mostly with total functions, but partial functions will come up in this course. By default, whenever we refer to a function in this course, we mean a total function. When we do want to talk about partial functions, we will explicitly use the term partial function. If f : A B is a total or partial function, then the domain of f is defined as follows: dom( f ) = {a A : (a, b) f for some b B}. Equivalently dom( f ) = {a A : f (a) is defined}. This means that if f : A B is a (total) function, then the domain of f is just A. The range of a total or partial function f : A B is defined as follows: range( f ) = { f (a) : a A}. Equivalently, range( f ) = {b B : (a, b) f for some b B}. A function f : A B is onto if range( f ) = B, and is 1-to-1 if it is the case that no two distinct elements of A are transformed to the same element b B. Formally, f is 1-to-1 if, for all a, c A and b B, we have [(a, b) f and (c, b) f ] [a = c].

You might also like