Mathematical Background 1

Slides:



Advertisements
Similar presentations
Chapter 2 Revision of Mathematical Notations and Techniques
Advertisements

The Engineering Design of Systems: Models and Methods
Discrete Structures Chapter 5 Relations and Functions Nurul Amelina Nasharuddin Multimedia Department.
Analytical Methods in CS (CIS 505)
Discrete Mathematics Lecture#11.
1 Section 7.1 Relations and their properties. 2 Binary relation A binary relation is a set of ordered pairs that expresses a relationship between elements.
Relations Chapter 9.
Week 8 - Wednesday.  What did we talk about last time?  Cardinality  Countability  Relations.
CS355 - Theory of Computation Lecture 2: Mathematical Preliminaries.
Chapter 9. Chapter Summary Relations and Their Properties Representing Relations Equivalence Relations Partial Orderings.
Week 15 - Wednesday.  What did we talk about last time?  Review first third of course.
Chapter 9. Chapter Summary Relations and Their Properties n-ary Relations and Their Applications (not currently included in overheads) Representing Relations.
R. Johnsonbaugh, Discrete Mathematics 5 th edition, 2001 Chapter 2 The Language of Mathematics.
Chapter 9. Section 9.1 Binary Relations Definition: A binary relation R from a set A to a set B is a subset R ⊆ A × B. Example: Let A = { 0, 1,2 } and.
CS 103 Discrete Structures Lecture 10 Basic Structures: Sets (1)
Sets Define sets in 2 ways  Enumeration  Set comprehension (predicate on membership), e.g., {n | n  N   k  k  N  n = 10  k  0  n  50} the set.
April 14, 2015Applied Discrete Mathematics Week 10: Equivalence Relations 1 Properties of Relations Definition: A relation R on a set A is called transitive.
Mathematical Notions and Terminology Lecture 2 Section 0.2 Fri, Aug 24, 2007.
Relations, Functions, and Countability
Language: Set of Strings
Fall 2015 COMP 2300 Discrete Structures for Computation Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University 1.
MATH 224 – Discrete Mathematics
Relations, Functions, and Matrices Mathematical Structures for Computer Science Chapter 4 Copyright © 2006 W.H. Freeman & Co.MSCS Slides Relations, Functions.
Discrete Mathematical Structures 4 th Edition Kolman, Busby, Ross © 2000 by Prentice-Hall, Inc. ISBN
Mathematical Preliminaries
Sets 2/10/121. What is a Set? Informally, a collection of objects, determined by its members, treated as a single mathematical object Not a real definition:
1 RELATIONS Learning outcomes Students are able to: a. determine the properties of relations – reflexive, symmetric, transitive, and antisymmetric b. determine.
Chapter 9. Chapter Summary Relations and Their Properties n-ary Relations and Their Applications (not currently included in overheads) Representing Relations.
Sets Definition: A set is an unordered collection of objects, called elements or members of the set. A set is said to contain its elements. We write a.
Representing Relations Using Matrices A relation between finite sets can be represented using a zero-one matrix Suppose R is a relation from A = {a 1,
Lecture 4 Infinite Cardinals. Some Philosophy: What is “2”? Definition 1: 2 = 1+1. This actually needs the definition of “1” and the definition of the.
Relations and Functions ORDERED PAIRS AND CARTESIAN PRODUCT An ordered pair consists of two elements, say a and b, in which one of them, say a is designated.
Week 7 - Wednesday.  What did we talk about last time?  Proving the subset relationship  Proving set equality  Set counterexamples  Laws of set algebra.
Week 8 - Wednesday.  What did we talk about last time?  Relations  Properties of relations  Reflexive  Symmetric  Transitive.
“It is impossible to define every concept.” For example a “set” can not be defined. But Here are a list of things we shall simply assume about sets. A.
Section 9.1. Section Summary Relations and Functions Properties of Relations Reflexive Relations Symmetric and Antisymmetric Relations Transitive Relations.
CSE 373, Copyright S. Tanimoto, 2002 Abstract Data Types - 1 Abstract Data Types Motivation Abstract Data Types Example Using math. functions to describe.
Binary Relation: A binary relation between sets A and B is a subset of the Cartesian Product A x B. If A = B we say that the relation is a relation on.
Relations and Their Properties
CHAPTER 2 Set Theory A B C.
CSE202: Introduction to Formal Languages and Automata Theory
Relations, Functions, and Matrices
Equivalence Relations
Relations Chapter 9.
Set, Combinatorics, Probability & Number Theory
Applied Discrete Mathematics Week 10: Relations
Representing Relations
Cartesian product Given two sets A, B we define their Cartesian product is the set of all the pairs whose first element is in A and second in B. Note that.
MATH 224 – Discrete Mathematics
Chapter 2 Sets and Functions.
Mathematical Notions and Terminology
Taibah University College of Computer Science & Engineering Course Title: Discrete Mathematics Code: CS 103 Chapter 2 Sets Slides are adopted from “Discrete.
Applied Discrete Mathematics Week 9: Equivalence Relations
CS201: Data Structures and Discrete Mathematics I
Chapter 2 Sets and Functions.
Discrete Math (2) Haiming Chen Associate Professor, PhD
CSE373: Data Structures & Algorithms Lecture 10: Disjoint Sets and the Union-Find ADT Linda Shapiro Spring 2016.
Yet another important mathematical concept
Introduction to Sets.
Advanced Algorithms Analysis and Design
Mathematical Background 1
Relations and their Properties
Discrete Mathematics CS 2610
Introduction to Relations and Functions
MCS680: Foundations Of Computer Science
Copyright © Cengage Learning. All rights reserved.
Mathematical Background
Copyright © Cengage Learning. All rights reserved.
Copyright © Cengage Learning. All rights reserved.
REVISION Relation. REVISION Relation Introduction to Relations and Functions.
Presentation transcript:

Mathematical Background 1 CSE 373 Data Structures

Basic Discrete Math Concepts Sets Cardinality Relations Cartesian Products Functions Properties of Functions 18 January 2019 CSE 373 AU 04- Math Background 1

CSE 373 AU 04- Math Background 1 Sets A set is a collection of distinct objects. (An object is some identifiable person, place, thing, or idea). The objects are usually represented by symbols. The set consisting of Jupiter and Saturn: {Jupiter, Saturn} 18 January 2019 CSE 373 AU 04- Math Background 1

CSE 373 AU 04- Math Background 1 Sets (Continued) The set consisting of the first 5 primes: { 2, 3, 5, 7, 11} The set consisting of all strings made up of only a and b. { “”, “a”, “b”, “aa”, “ab”, “ba”, “bb”, . . . } (or, without the use of quotes...) { λ, a, b, aa, ab, ba, bb, . . . } 18 January 2019 CSE 373 AU 04- Math Background 1

CSE 373 AU 04- Math Background 1 Sets (continued) The objects that make up a set are called its elements or members. If an object e is an elements of a set S, then we write e  S The empty set { } contains zero elements. A set may contain other sets as members: { {a}, {b}, {a, b} } contains three (top-level) elements. { { } } contains one element. 18 January 2019 CSE 373 AU 04- Math Background 1

CSE 373 AU 04- Math Background 1 Cardinality A set may be finite or infinite. The cardinality of a finite set is the number of (top-level) elements it contains. Card( { a, b, c } ) = 3 We sometimes use vertical bars: | { a, b, c } | = 3 18 January 2019 CSE 373 AU 04- Math Background 1

CSE 373 AU 04- Math Background 1 Binary Relations Suppose S is a set. Let a  S and b  S. Then (a, b) is an ordered pair of elements of S. The set of all ordered pairs over S is: { (x, y) | x  S, y  S } = the set of all ordered pairs (x, y) such that x is in S and y is in S. Any set of ordered pairs over S is called a binary relation on S. 18 January 2019 CSE 373 AU 04- Math Background 1

Binary Relations (cont) Examples: Let S = { a, b, c } B1 = { (a, b), (c, b), (c, c) } is a binary relation on S. B2 = { (a, a), (b, b), (c, c) } is a binary relation on S. It happens to be reflexive. B3 = { } is a binary relation on S. It happens to be empty. 18 January 2019 CSE 373 AU 04- Math Background 1

Binary Relations (reflexivity) A binary relation on S is reflexive provided that for every element in S, the pair of that element with itself is a pair in S. S = { a, b, c } R4 = { (a, a), (a, b), (b, b), (b, c), (c, c) } is reflexive. R5 = { (a, a), (a, b), (b, b) } is not reflexive, because c  S but (c, c) R5. 18 January 2019 CSE 373 AU 04- Math Background 1

Binary Relations (symmetry) A binary relation R on S is symmetric provided that any pair that occurs in R also occurs “reversed” in R. S = { a, b, c } R6 = { (a, b), (b, a), (c, c) } is symmetric. { } is symmetric. R7 = { (a, b), (b, b), (c, c) } is not symmetric, because (a, b)  R7 but (b, a) R7. 18 January 2019 CSE 373 AU 04- Math Background 1

Binary Relations (transitivity) A binary relation B on S is transitive provided that whenever there is a two-element “chain” in B there is also the corresponding “shortcut” in B. B is transitive iff (x  S,  y  S,  z  S) (x, y)  B and (y, z)  B  (x, z)  B) R8 = { (a, b), (a, c), (b, c), (c, c) } is transitive. R9 = { (a, b), (b, a)} is not transitive, because (a, b) and (b, a) form a chain, but (a, a), the shortcut, is not present. 18 January 2019 CSE 373 AU 04- Math Background 1

Equivalence Relations A binary relation B on S is an equivalence relation provided that it is reflexive (on S), symmetric, and transitive. R10 = { (a, a), (a, b), (b, a), (b, b), (c, c) } is an equivalence relation. R9 = { (a, a), (a, b), (b, b), (b, c), (c, c)} is not an equivalence relation; although it is reflexive on {a, b, c}, it is not symmetric, and it is not transitive. When we study the UNION-FIND abstract data type, we will use equivalence relations. 18 January 2019 CSE 373 AU 04- Math Background 1

Binary Relations (antisymmetry) A binary relation R on S is antisymmetric provided that any time we have, for some x and y, (x,y)  R and (y,x)  R, then x = y. For example, the relation  on the set of real numbers is antisymmetric, because any time we have x  y and y  x, it must be true that x = y. R11 = { (a, b), (a, c), (c, c) } is antisymmetric, since the only way we could have x  y and y  x would be if x and y were both equal to c. { } is antisymmetric, since there are no violations of the antisymmetry condition. 18 January 2019 CSE 373 AU 04- Math Background 1

CSE 373 AU 04- Math Background 1 Induced Relations Facts can be used to construct or “induce” a relation on an appropriate set of objects. Example: people have birthdays. This can be used to induce a relation R on the set of people P where (p1, p2) are in R iff p1 was born before p2. We can then talk about the properties of R. A different relation on the same set would be S, where (p1, p2) are in S iff p1 and p2 were born on the same day. 18 January 2019 CSE 373 AU 04- Math Background 1

CSE 373 AU 04- Math Background 1 Cartesian Products Let S1 and S2 be sets. Then the Cartesian product S1 X S2 is the set of all ordered pairs in which the first element is a member of S1 and the second element is a member of S2. Example: Let A = { a, b, c }, Let B = { 1, 2 } then A X B = { (a, 1), (a, 2), (b, 1), (b, 2), (c, 1), (c, 2) } 18 January 2019 CSE 373 AU 04- Math Background 1

Cartesian Products (n-way) The n-way Cartesian product S1 X S2 X ... X Sn is the set of all ordered n-tuples in which the ith element is an element of Si. S1 X S2 X ... X Sn = { (s1, s2, ..., sn ) | s1S1, s2S2, ..., s2S2 } 18 January 2019 CSE 373 AU 04- Math Background 1

Cartesian Products: Non-associativity The Cartesian product operation (binary or n-way) is not associative. S1 X (S2 X S3 )  (S1 X S2) X S3 This is clear because the elements of the two sets have different structures: (a, (b, c))  ((a, b), c) 18 January 2019 CSE 373 AU 04- Math Background 1

CSE 373 AU 04- Math Background 1 Functions Let S1 and S2 be sets. Let f be a subset of S1 X S2. (f is a binary relation on S1 and S2) If for each x in S1 there is precisely one y in S2 such that (x, y)  f, then f is a function from S1 to S2. We also say f is a function on S1. S1 is called the domain of f and S2 is called the range of f. 18 January 2019 CSE 373 AU 04- Math Background 1

CSE 373 AU 04- Math Background 1 Functions (Examples) Let S1 = { a, b, c} and S2 = { 1, 2}. Let f1 = { (a, 1), (b, 1), (c, 2) } f1 is a function on S1. Let f2 = { (a, 1), (b, 1), (b, 2), (c, 1) } f2 is not a function. Let f3 = { (a, 1), (b, 2)} f3 is not a function on S1. But it is a partial function on S1. It’s actually a function on { a, b }. 18 January 2019 CSE 373 AU 04- Math Background 1

Properties of Functions Let f be a function from S1 to S2. If every element of S2 appears as the second element of some ordered pair in f, then f is said to be “onto”. (It’s also said to be a surjection.) With S1 = { a, b, c} and S2 = { 1, 2}. and f1 = { (a, 1), (b, 1), (c, 2) }, f1 is onto. Let f4 = { (a, 1), (b, 1), (c, 1) } with the same domain and range. f4 is not onto. 18 January 2019 CSE 373 AU 04- Math Background 1

Properties of Functions (cont) Let f be a function from S1 to S2. If no two elements of S1 are paired with the same element of S2 then f is said to be “one-to-one”. (It’s also said to be a injection.) With S1 = { a, b, c} and S2 = { 1, 2}. and f1 = { (a, 1), (b, 1), (c, 2) }, f1 is not one-to-one, since a and b are both paired with 1. Let f5 = { (a, 1), (b, 2)} with domain { a, b}. f5 is one-to-one. 18 January 2019 CSE 373 AU 04- Math Background 1

Properties of Functions Let S1 = { a, b, c} and S2 = { 1, 2}. Let f1 = { (a, 1), (b, 1), (c, 2) } f1 is a function on S1. Let f2 = { (a, 1), (b, 1), (b, 2), (c, 1) } f2 is not a function. Let f3 = { (a, 1), (b, 2)} f3 is not a function on S1. But it is a partial function on S1. It’s actually a function on { a, b }. 18 January 2019 CSE 373 AU 04- Math Background 1

CSE 373 AU 04- Math Background 1 Abstract Data Types Motivation Abstract Data Types Example Using math. functions to describe an ADT's operations. 18 January 2019 CSE 373 AU 04- Math Background 1

CSE 373 AU 04- Math Background 1 Motivation for ADTs To organize some data, we need to say what general form it has, and what we expect to do with it. Object-oriented programming provides one way of organizing data: using classes, with their data members and methods. It is often helpful to specify our data without having to choose the particular data structure yet. 18 January 2019 CSE 373 AU 04- Math Background 1

Abstract Data Type (Def.) An abstract data type consists of two parts: a description of the general form of some data. a set of methods. The data is usually a set of elements, but may also include relationships among the elements. { 2, 3, 5, 7, 11} [2 < 3, 3 < 5, 5 < 7, 7 < 11, etc.] 18 January 2019 CSE 373 AU 04- Math Background 1

CSE 373 AU 04- Math Background 1 ADT Methods Each method in an ADT names and specifies an operation. The operation can be described by a function. Normally, an instance of the ADT data is one of the arguments to the function. Examples of methods: INSERT(x) MEMBER(x) SMALLEST( ) CREATE( ) --- A "constructor" does not use an instance of the ADT, but creates one. 18 January 2019 CSE 373 AU 04- Math Background 1

Example ADT: Stack of Integers Data: (Ordered) list of integers. Methods: CREATE, PUSH, POP, TOP, DESTROY 18 January 2019 CSE 373 AU 04- Math Background 1

Using Math. Functions to Describe ADT Methods Why? Math. can be used to give a concise and unambiguous description of a method. What? 1. gives a clear indication of input & output. 2. clarifies how the data changes and what is returned by the operation. 18 January 2019 CSE 373 AU 04- Math Background 1

Math. Description of Methods: Domain and Range of the Method's function Example: the POP operation on a stack can be described by a mathematical function: fPOP: stacks  elements  stacks stacks = the set of all possible stacks (according to this ADT). elements = the set of all acceptable elements in our stacks (e.g., integers). Because the operation produces an element and it causes a change to the stack, the range of fPOP is a cartesian product. 18 January 2019 CSE 373 AU 04- Math Background 1

The Function's Effect Now we describe how the function changes the stack and produces a value. fPOP : [e0,e1,...,en-1] | ( en-1, [e0,e1,...,en-2] ) The symbol " | " means "maps to". On its left side is a description of a generic domain element. On its right side is a description of the corresponding range element. This formula indicates that the POP operation takes an n-element stack, returns the last element, and removes it from the stack. 18 January 2019 CSE 373 AU 04- Math Background 1