CS100: DISCRETE STRUCTURES

Similar documents
Taibah University College of Computer Science & Engineering Course Title: Discrete Mathematics Code: CS 103. Chapter 2. Sets

SET DEFINITION 1 elements members

CSC Discrete Math I, Spring Sets

Set and Set Operations

2.1 Sets 2.2 Set Operations

9/19/12. Why Study Discrete Math? What is discrete? Sets (Rosen, Chapter 2) can be described by discrete math TOPICS

Sets. Mukulika Ghosh. Fall Based on slides by Dr. Hyunyoung Lee

Discrete Mathematics

Review of Sets. Review. Philippe B. Laval. Current Semester. Kennesaw State University. Philippe B. Laval (KSU) Sets Current Semester 1 / 16

Introduction II. Sets. Terminology III. Definition. Definition. Definition. Example

Sets MAT231. Fall Transition to Higher Mathematics. MAT231 (Transition to Higher Math) Sets Fall / 31

2.2 Set Operations. Introduction DEFINITION 1. EXAMPLE 1 The union of the sets {1, 3, 5} and {1, 2, 3} is the set {1, 2, 3, 5}; that is, EXAMPLE 2

Today s Topics. What is a set?

1.1 - Introduction to Sets

[Ch 6] Set Theory. 1. Basic Concepts and Definitions. 400 lecture note #4. 1) Basics

What is Set? Set Theory. Notation. Venn Diagram

2. Sets. 2.1&2.2: Sets and Subsets. Combining Sets. c Dr Oksana Shatalov, Fall

2 Review of Set Theory

c) the set of students at your school who either are sophomores or are taking discrete mathematics

Introduction. Sets and the Real Number System

SETS. Sets are of two sorts: finite infinite A system of sets is a set, whose elements are again sets.

2/18/14. Uses for Discrete Math in Computer Science. What is discrete? Why Study Discrete Math? Sets and Functions (Rosen, Sections 2.1,2.2, 2.


2.1 Symbols and Terminology

Discrete Mathematics Lecture 4. Harper Langston New York University

SEVENTH EDITION and EXPANDED SEVENTH EDITION

Sets and set operations

About the Tutorial. Audience. Prerequisites. Copyright & Disclaimer. Discrete Mathematics

CS 1200 Discrete Math Math Preliminaries. A.R. Hurson 323 CS Building, Missouri S&T

A set with only one member is called a SINGLETON. A set with no members is called the EMPTY SET or 2 N

Chapter 2: Sets. Diana Pell. In the roster method: elements are listed between braces, with commas between the elements

The Language of Sets and Functions

This Lecture. We will first introduce some basic set theory before we do counting. Basic Definitions. Operations on Sets.

Sets 1. The things in a set are called the elements of it. If x is an element of the set S, we say

Outline. CISC 1100/1400 Structures of Comp. Sci./Discrete Structures Chapter 1 Sets. Sets. Enumerating the elements of a set

Chapter 3. Set Theory. 3.1 What is a Set?

Math Week in Review #5

Definition. A set is a collection of objects. The objects in a set are elements.

COLLEGE ALGEBRA. Intro, Sets of Real Numbers, & Set Theory

Math Week in Review #5. A proposition, or statement, is a declarative sentence that can be classified as either true or false, but not both.

11 Sets II Operations

Figure 1: From Left to Right, General Venn Diagrams for One, Two, and Three Sets

1.2 Venn Diagrams and Partitions

In this section we take an aside from the normal discussion in algebra.

What is a Set? Set Theory. Set Notation. Standard Sets. Standard Sets. Part 1.1. Organizing Information

Sets and set operations. Lecture 5 ICOM 4075

The set consisting of all natural numbers that are in A and are in B is the set f1; 3; 5g;

Question7.How many proper subsets in all are there if a set contains (a) 7 elements (b) 4 elements

Sets. X. Zhang Dept. of Computer & Information Sciences Fordham University

CSE 20 DISCRETE MATH. Fall

Math 110 FOUNDATIONS OF THE REAL NUMBER SYSTEM FOR ELEMENTARY AND MIDDLE SCHOOL TEACHERS

Section Sets and Set Operations

1 Sets, Fields, and Events

9.5 Equivalence Relations

Slides for Faculty Oxford University Press All rights reserved.

CSE 215: Foundations of Computer Science Recitation Exercises Set #9 Stony Brook University. Name: ID#: Section #: Score: / 4

CSE 20 DISCRETE MATH. Winter

CS402 - Theory of Automata Glossary By

Relational terminology. Databases - Sets & Relations. Sets. Membership

Section 1.1. Inductive Reasoning. Copyright 2013, 2010, 2007, Pearson, Education, Inc.

Computer Science and Mathematics. Part I: Fundamental Mathematical Concepts Winfried Kurth

LECTURE 8: SETS. Software Engineering Mike Wooldridge

Set theory is a branch of mathematics that studies sets. Sets are a collection of objects.

Lecture 6,

CS Bootcamp Boolean Logic Autumn 2015 A B A B T T T T F F F T F F F F T T T T F T F T T F F F

Lectures on Order and Topology

Complexity Theory. Compiled By : Hari Prasad Pokhrel Page 1 of 20. ioenotes.edu.np

1. The collection of the vowels in the word probability. 2. The collection of real numbers that satisfy the equation x 9 = 0.

Problem One: A Quick Algebra Review

Section 1.1. Inductive Reasoning. Copyright 2013, 2010, 2007, Pearson, Education, Inc.

CHAPTER 8. Copyright Cengage Learning. All rights reserved.

Summary of Course Coverage

COMS 1003 Fall Introduction to Computer Programming in C. Bits, Boolean Logic & Discrete Math. September 13 th

Calculating Cardinalities

IB Sets and Venn Diagram Questions- Package #1

A.1 Numbers, Sets and Arithmetic

CMPSCI 250: Introduction to Computation. Lecture #7: Quantifiers and Languages 6 February 2012

Power Set of a set and Relations

COUNTING AND PROBABILITY

Let A(x) be x is an element of A, and B(x) be x is an element of B.

Fault Tree Analysis (Minimal Cutset)

CS 441 Discrete Mathematics for CS Lecture 24. Relations IV. CS 441 Discrete mathematics for CS. Equivalence relation

LECTURE NOTES ON SETS

The Size of the Cantor Set

CHAPTER 3 FUZZY RELATION and COMPOSITION

Lecture 15: The subspace topology, Closed sets

CS314: FORMAL LANGUAGES AND AUTOMATA THEORY L. NADA ALZABEN. Lecture 1: Introduction

Phil 320 Chapter 1: Sets, Functions and Enumerability I. Sets Informally: a set is a collection of objects. The objects are called members or

About the Tutorial. Audience. Prerequisites. Copyright & Disclaimer. Discrete Mathematics

2 Sets. 2.1 Notation. last edited January 26, 2016

The Intersection of Two Sets

Section 6.3: Further Rules for Counting Sets

Sets. {1, 2, 3, Calvin}.

Figure 1.1: This is an illustration of a generic set and its elements.

Binary Relations McGraw-Hill Education

MATH 22 MORE ABOUT FUNCTIONS. Lecture M: 10/14/2003. Form follows function. Louis Henri Sullivan

10/11/2018. Partial Orderings. Partial Orderings. Partial Orderings. Partial Orderings. Partial Orderings. Partial Orderings

1. Chapter 1, # 1: Prove that for all sets A, B, C, the formula

A graph is finite if its vertex set and edge set are finite. We call a graph with just one vertex trivial and all other graphs nontrivial.

CS February 17

Transcription:

CS: DISCRETE STRUCTURES Computer Science Department Lecture : Set and Sets Operations (Ch2)

Lecture Contents 2 Sets Definition. Some Important Sets. Notation used to describe membership in sets. How to describe a set? Sets. Venn diagrams. Subset. Finite and Infinite Sets. Cardinality.

Lecture Contents 3 Sets Definition. Sets. The power of a set. Cartesian Products. Sets Operations. Exercises.

4 Sets and sets operations Sets Reading: Ch:2./ Pages: -9

Sets Definition: 5 Set is the fundamental discrete structure on which all other discrete structures are built. Sets are used to group objects together. Often, the objects in a set have similar properties. A set is an unordered collection of objects. The objects in a set are called the elements or members of the set

Some Important Sets: 6 The set of natural numbers: N = {,, 2, 3,...} The set of integers: Z = {..., 2,,,, 2,...} The set of positive integers: Z + = {, 2, 3,...} The set of fractions: Q = {,½, ½, 5, 78/3, } Q ={p/q pє Z, qєz, and q } The set of Real: R = { 3/2,,e,π2,sqrt(5), }

Notation used to describe membership in sets 7 o a set A is a collection of elements. o If x is an element of A, we write xîa; If not: xïa. o xîa Say: x is a member of A or x is in A. o Note: Lowercase letters are used for elements, capitals for sets. o Two sets are equal if and only if they have the same elements A= B : "x( x ÎA «x ÎB) also o Two sets A and B are equal if A Í B and B Í A. o So to show equality of sets A and B, show: A Í B B Í A

Notation used to describe membership in sets 8 The sets {,3,5} and {3,5,} are equal, because they have the same elements.

How to describe a set? 9. List all the members of a set, when this is possible. We use a notation where all members of the set are listed between braces. { } Example : {dog, cat, horse} The set O of odd positive integers less than can be expressed by O={,3,5,7,9}

How to describe a set? 2. Sometimes the brace notation is used to describe a set without listing all its members. Some members of the set are listed, and then ellipses (...) are used when the general pattern of the elements is obvious. Example: The set A of positive integers less than can be denoted by A={, 2, 3,..., 99}

How to describe a set? 3. Another way to describe a set is to use set builder notation. We characterize all those elements in the set by stating the property or properties they must have to be members. Example: the set O of all odd positive integers less than can be written as: n O = {x x is an odd positive integer <} or, specifying the universe as the set of positive integers, as n O = {x Î Z+ x is odd and x<}.

Sets: 2 The Empty Set (Null Set) We use Æ to denote the empty set and can also be denoted { }, i.e. the set with no elements. Example: the set of all positive integers that are greater than their squares is the null set. Singleton set A set with one element is called a singleton set.

Sets: 3 Computer Science Note that the concept of a data type, or type, in computer science is built upon the concept of a set. In particular, a data type is the name of a set, together with a set of operations that can be performed on objects from that set. Example: Boolean is the name of the set {, } together with operators on one or more elements of this set, such as AND, OR, and NOT.

Venn diagrams: 4 Sets can be represented graphically using Venn diagrams. In Venn diagrams the universal set U, which contains all the objects under consideration, is represented by a rectangle. Inside this rectangle, circles or other geometrical figures are used to represent sets. Sometimes points are used to represent the particular elements of the set.

Venn diagrams: 5 Example: A Venn diagram that represents V = {a, e, i, o, u} the set of vowels in the English alphabet

Subset: 6 The set A is said to be a subset of B if and only if every element of A is also an element of B. We use the notation A Í B to indicate that A is a subset of the set B. We see that A Í B if and only if the quantification "x (x Î A x Î B) is true. Examples: The set of all odd positive integers less than is subset of the set of all positive integers. The set of rational numbers is subset of the set of real numbers.

Subsets: 7 For every set S, Æ Í S S Í S Proper subset: When a set A is a subset of a set B but A B, A Í B, and A ¹ B We write A Ì B and say that A is a proper subset of B For A Ì B to be true, it must be the case that "x ((x Î A) (x Î B)) Ù $x ((x Î B) Ù (x Ï A))

Subsets: 8 Quick Examples: {,2,3} Í {,2,3,4,5} {,2,3} Ì {,2,3,4,5} Is Æ Í {,2,3}? Is Æ Î {,2,3}? Is Æ Í {Æ,,2,3}? Is Æ Î {Æ,,2,3}? Yes! No! Yes! Yes!

Subsets: 9 Quiz Time: Is {x} Î {x,{x}}? Is {x} Í {x,{x}}? Is {x} Í {x}? Is {x} Î {x}?

Finite and Infinite Sets: 2 Finite set Let S be a set. If there are exactly n distinct elements in S where n is a nonnegative integer, we say that S is a finite set and that n is the cardinality of S. The cardinality of S is denoted by S. A È B = A + B - A Ç B Infinite set A set is said to be infinite if it is not finite. For example, the set of positive integers is infinite. N.B. We only count unrepeated elements

Cardinality: 2 Find S = {,2,3}, S = {3,3,3,3,3}, S = Æ, S = 3. S = S =. S = { Æ, {Æ}, {Æ,{Æ}} }, S = 3. S = {,,2,3, }, S is infinite

Sets: 22 Ways to Define Sets: Explicitly: {John, Paul, George, Ringo} Implicitly: {,2,3, }, or {2,3,5,7,,3,7, } Set builder: { x : x is prime }, { x x is odd }. In general { x : P(x) is true }, where P(x) is some description of the set.

The power of a set: 23 Many problems involve testing all combinations of elements of a set to see if they satisfy some property. To consider all such combinations of elements of a set S, we build a new set that has as its members all the subsets of S. Given a set S, the power set of S is the set of all subsets of the set S. The power set of S is denoted by P(S). if a set has n elements, then the power has 2 n elements.

The power of a set: 24 Example: What is the power set of the set {,, 2}? P({,,2}) is the set of all subsets of {,, 2} P({,,2})= {Æ, {},{},{2},{,},{,2},{,2},{,,2}} What is the power set of the empty set? What is the power set of the set {Æ}? P(Æ)= {Æ} P({Æ})= {Æ,{Æ}} N.B. the power set of any subset has at least two elements The null set and the set itself

The Power Set: 25 Quick Quiz: Find the power set of the following: S = {a}, S = {a,b}, S = Æ, S = {Æ,{Æ}},

Cartesian Products: 26 The order of elements in a collection is often important. Because sets are unordered, a different structure is needed to represent ordered collections. This is provided by ordered n-tuples. The ordered n-tuple (a, a2,..., a n ) is the ordered collection that has a as its first element, a 2 as its second element,..., and a n as its n th element.

Cartesian Products: 27 Let A and B be sets. The Cartesian product of A and B, denoted by A B, is the set of all ordered pairs (a, b), where aîa and bîb. A B = {(a, b) a Î A Ù b Î B}. A A 2 A n= {(a, a 2,, a n ) a i ÎA i for i=,2,,n}. A B not equal to B A Example : A={,2}, B={3,4} A B={(,3),(,4),(2,3),(2,4)} B A={(3,),(3,2),(4,),(4,2)}

Cartesian Products: 28 Example: What is the Cartesian product A B C, where A = {, }, B = {, 2}, and C = {,, 2}? AxBxC = {(,,), (,,), (,,2), (,2,), (,2,), (,2,2), (,,), (,,), (,,2), (,2,), (,2,), (,2,2)}

29 Sets and sets operations Sets Operations Reading: Ch:2.2/ Pages: 2-3

UNION: 3 The union of two sets A and B is: A È B = { x : x Î A v x Î B} If A = {, 2, 3}, and B = {2, 4}, then A È B = {,2,3,4} B A

Intersection: 3 The intersection of two sets A and B is: A Ç B = { x : x Î A Ù x Î B} If A = {Charlie, Lucy, Linus}, and B = {Lucy, Desi}, then B A Ç B = {Lucy} A

Intersection: 32 If A = {x : x is a US president}, and B = {x : x is deceased}, then A Ç B = {x : x is a deceased US president} B A

Disjoint: 33 If A = {x : x is a US president}, and B = {x : x is in this room}, then A Ç B = {x : x is a US president in this room} = B A Sets whose intersection is empty are called disjoint sets

Complement: 34 The complement of a set A is: A" = A = { x : x Ï A} If A = {x : x is bored}, then A" = {x : x is not bored} = Æ A Í B = B Í A U A Æ = U and U = Æ

Difference: 35 The set difference, A - B, is: U B A A - B = { x : x Î A Ù x Ï B } A - B = A Ç B"

Symmetric Difference: 36 The symmetric difference, A Å B, is: A Å B = { x : (x Î A Ù x Ï B) v (x Î B Ù x Ï A)} = (A - B) È (B - A) U B A Like exclusive or

Symmetric Difference: 37 Example: Let A = {,2,3,4,5,6,7} B = {3,4,p,q,r,s} Then we have A È B = {,2,3,4,5,6,7,p,q,r,s} A Ç B = {3,4} We get A Å B = {,2,5,6,7,p,q,r,s}

38 TABLE : Set Identities Identity A U Æ = A A Ç U = A A U U = U A Ç Æ = Æ A È A = A A Ç A = A (A) = A A È B = B È A A Ç B = B Ç A A È (B È C) = (A È B) È C A Ç (B Ç C) = (A Ç B) Ç C A Ç (B U C) = (A Ç B) È (A Ç C) A È (B Ç C) = (A U B) Ç (A U C) A U B = A Ç B A Ç B = A U B A È (A Ç B) = A A Ç (A È B) = A A È A = U A Ç A = Æ Name Identity laws Domination laws Idempotent laws Complementation laws Commutative laws Associative laws Distributive laws De Morgan s laws Absorption laws Complement laws

39 Let s proof one of the Identities Using a Membership Table A Ç (B È C) = (A Ç B) È (A Ç C) TABLE 2: A Membership Table for the Distributive Property (A Ç B) È (A Ç C) A Ç C A Ç B A Ç (B È C) B È C C B A

Exercise : 4 List the members of these sets: a) {x x is a real number such that x² = } b) {x x is a positive integer less than 2} c) {x x is the square of an integer and x < } d) {x x is an integer such that x² = 2}

Exercise 2: 4 Determine whether each of these pairs of sets are equal: a) {4, 3, 3, 7, 4, 7, 7, 3}, {4, 3, 7} b) {{}}, {, {2}} c) Æ, {Æ}

Exercise 3: 42 Determine whether these statements are true or false. a) b) {} c) {} d) {} e) {} {} f) {} {} g) { } { }

Exercise 4: 43 Use a Venn diagram to illustrate the relationships A B and B C.

Exercise 5: 44 What is the cardinality of each of these sets? a) {a} b) {{a}} c) {, { }} d) {a, {a}, {a, {a}}}

Exercise 6: 45 Let A = {, 2, 3, 4, 5} and B = {, 3, 6}. Find : a) A B b) A B c) A B d) B A

Exercise 7: 46 For U = {, 2,3, 4,5,6,7,8,9,} let A = {, 2,3,4,5}, B = {,2, 4,8}, C = {, 2,3,5,7}, and D = {2, 4,6,8}. Determine each of the following: a) (A B) C = b) A (B C)= c) C D = d) (A B) C = e) A (B C)= f) (B C) D = g) B (C D)= h) (A B) (C D)= i) A B =

Exercise 8: 47 Draw the VENN DIAGRAM of these sets and find (A B) C and Bʹ

Exercise 9: 48 Given the Universal set U={positive integers not larger than 2}, and the sets : A={positive integers not more than 6} B={3,4,6,7}, C={5,6,7,8,9,}, Find : i) A U B = ii) A B = iii) P(A-B)=Power set of (A-B)=