Discrete Mathematics and its Applications

Slides:



Advertisements
Similar presentations
1 Relations Rosen 5 th ed., ch Relations Relationships between elements of sets occur very often.Relationships between elements of sets occur very.
Advertisements

Module #1 - Logic 1 Based on Rosen, Discrete Mathematics & Its Applications. Prepared by (c) , Michael P. Frank and Modified By Mingwu Chen Relations.
Relations Chapter 9.
Applied Discrete Mathematics Week 10: Equivalence Relations
Relations (1) Rosen 6 th ed., ch. 8. Binary Relations Let A, B be any two sets. A binary relation R from A to B, written (with signature) R:A↔B, is a.
Module #21 - Relations Representing Relations Rosen 6 th ed., Ch. 8.
Module #18: Relations, part I
Relations Rosen 5 th ed., ch. 7. Binary Relations Let A, B be any sets. A binary relation R from A to B, written (with signature) R:A×B, or R:A,B, is.
Chapter 9. Chapter Summary Relations and Their Properties Representing Relations Equivalence Relations Partial Orderings.
Chapter 9. Chapter Summary Relations and Their Properties n-ary Relations and Their Applications (not currently included in overheads) Representing Relations.
Discrete Math for CS 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.
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.
Discrete Mathematics and Its Applications Sixth Edition By Kenneth Rosen Chapter 8 Relations 歐亞書局.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Relations.
Relations and their Properties
Sets and Subsets Set A set is a collection of well-defined objects (elements/members). The elements of the set are said to belong to (or be contained in)
Relations. Important Definitions We covered all of these definitions on the board on Monday, November 7 th. Definition 1 Definition 2 Definition 3 Definition.
이산수학 (Discrete Mathematics) 7.3 관계의 표현 (Representing Relations) 2006 년 봄학기 문양세 강원대학교 컴퓨터과학과.
Discrete Mathematics Lecture # 15 Types of Relations (contd.)
Problem Statement How do we represent relationship between two related elements ?
Chapter 9. Chapter Summary Relations and Their Properties n-ary Relations and Their Applications (not currently included in overheads) Representing Relations.
Unit II Discrete Structures Relations and Functions SE (Comp.Engg.)
Chapter 8: Relations. 8.1 Relations and Their Properties Binary relations: Let A and B be any two sets. A binary relation R from A to B, written R : A.
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.
Chapter8 Relations 8.1: Relations and their properties.
15.1 CompSci 102© Michael Frank Today’s topics RelationsRelations –Kinds of relations –n-ary relations –Representations of relations Reading: Sections.
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 Chapter 9 Copyright © McGraw-Hill Education. All rights reserved. No reproduction or distribution without the prior written consent of McGraw-Hill.
Representing Relations Using Digraphs
Discrete Mathematical
Relations and Their Properties
Citra Noviyasari, S.Si, MT
Chapter 5 Relations and Operations
Relations.
Relations Binary relations represent relationships between the elements of two sets. A binary relation R from set A to set B is defined by: R  A 
Relations Chapter 9.
Relations and Digraphs
Applied Discrete Mathematics Week 10: Relations
RELATION KS MATEMATIKA DISKRIT (DISCRETE MATHEMATICS )
Dr. Ameria Eldosoky Discrete mathematics
CSE115/ENGR160 Discrete Mathematics 04/28/11
Relations Rosen 5th ed., ch. 7.
CSNB 143 Discrete Mathematical Structures
Taibah University College of Computer Science & Engineering Course Title: Discrete Mathematics Code: CS 103 Chapter 2 Sets Slides are adopted from “Discrete.
Taibah University College of Computer Science & Engineering Course Title: Discrete Mathematics Code: CS 103 Chapter 9 Relations Slides are adopted from.
CMSC Discrete Structures
CS201: Data Structures and Discrete Mathematics I
Applied Discrete Mathematics Week 10: Equivalence Relations
§7.3 Representing Relations Longin Jan Latecki
CS2210 Discrete Structures Relations
Rosen 5th ed., ch. 7 ~32 slides (in progress), ~2 lectures
Relations and Their Properties
Discrete Mathematics and its Applications
Relations and Digraphs
Applied Discrete Mathematics Week 6: Relations/Digraphs
Introduction to Relations and Functions
2/18/2019 §7.1 Binary Relations (2nd pass) and §7.2 n-ary Relations Longin Jan Latecki Slides adapted from Kees van Deemter who adopted them from Michael.
Discrete Mathematics and its Applications
2/25/2019 §7.1 Binary Relations (2nd pass) and §7.2 n-ary Relations Longin Jan Latecki Slides adapted from Kees van Deemter who adopted them from Michael.
Discrete Mathematics and its Applications
Properties of Relations
교환 학생 프로그램 내년 1월 중순부터 6월 초 현재 학부 2,3 학년?
Discrete Mathematics and its Applications
REVISION Relation. REVISION Relation Introduction to Relations and Functions.
§7.3 Representing Relations Longin Jan Latecki
7/30/2019 §7.1 Binary Relations (2nd pass) and §7.2 n-ary Relations Longin Jan Latecki Slides adapted from Kees van Deemter who adopted them from Michael.
Chapter 8 (Part 2): Relations
Agenda Lecture Content: Relations (Relasi)
Lecture # 16 Inverse of Relations
Relations 12/7/2019.
Presentation transcript:

Discrete Mathematics and its Applications 9/21/2018 University of Florida Dept. of Computer & Information Science & Engineering COT 3100 Applications of Discrete Structures Dr. Michael P. Frank Slides for a Course Based on the Text Discrete Mathematics & Its Applications (5th Edition) by Kenneth H. Rosen A word about organization: Since different courses have different lengths of lecture periods, and different instructors go at different paces, rather than dividing the material up into fixed-length lectures, we will divide it up into “modules” which correspond to major topic areas and will generally take 1-3 lectures to cover. Within modules, we have smaller “topics”. Within topics are individual slides. 9/21/2018 (c)2001-2003, Michael P. Frank (c)2001-2002, Michael P. Frank

Rosen 5th ed., ch. 7 ~35 slides (in progress), ~2 lectures Module #21: Relations Rosen 5th ed., ch. 7 ~35 slides (in progress), ~2 lectures 9/21/2018 (c)2001-2003, Michael P. Frank

Binary Relations Let A, B be any sets. A binary relation R from A to B, written (with signature) R:A×B, or R:A,B, is (can be identified with) a subset of the set A×B. E.g., let < : N↔N :≡ {(n,m) | n < m} The notation a R b or aRb means that (a,b)R. E.g., a < b means (a,b) < If aRb we may say “a is related to b (by relation R)”, or just “a relates to b (under relation R)”. A binary relation R corresponds to a predicate function PR:A×B→{T,F} defined over the 2 sets A,B; e.g., predicate “eats” :≡ {(a,b)| organism a eats food b} 9/21/2018 (c)2001-2003, Michael P. Frank

Complementary Relations Let R:A,B be any binary relation. Then, R:A×B, the complement of R, is the binary relation defined by R :≡ {(a,b) | (a,b)R} = (A×B) − R Note this is just R if the universe of discourse is U = A×B; thus the name complement. Note the complement of R is R. Example: < = {(a,b) | (a,b)<} = {(a,b) | ¬a<b} = ≥ 9/21/2018 (c)2001-2003, Michael P. Frank

Inverse Relations Any binary relation R:A×B has an inverse relation R−1:B×A, defined by R−1 :≡ {(b,a) | (a,b)R}. E.g., <−1 = {(b,a) | a<b} = {(b,a) | b>a} = >. E.g., if R:People→Foods is defined by a R b  a eats b, then: b R−1 a  b is eaten by a. (Passive voice.) 9/21/2018 (c)2001-2003, Michael P. Frank

Relations on a Set A (binary) relation from a set A to itself is called a relation on the set A. E.g., the “<” relation from earlier was defined as a relation on the set N of natural numbers. The (binary) identity relation IA on a set A is the set {(a,a)|aA}. 9/21/2018 (c)2001-2003, Michael P. Frank

Reflexivity A relation R on A is reflexive if aA, aRa. E.g., the relation ≥ :≡ {(a,b) | a≥b} is reflexive. A relation R is irreflexive iff its complementary relation R is reflexive. Example: < is irreflexive, because ≥ is reflexive. Note “irreflexive” does NOT mean “not reflexive”! For example: the relation “likes” between people is not reflexive, but it is not irreflexive either. Since not everyone likes themselves, but not everyone dislikes themselves either! 9/21/2018 (c)2001-2003, Michael P. Frank

Symmetry & Antisymmetry A binary relation R on A is symmetric iff R = R−1, that is, if (a,b)R ↔ (b,a)R. E.g., = (equality) is symmetric. < is not. “is married to” is symmetric, “likes” is not. A binary relation R is antisymmetric if a≠b, (a,b)R → (b,a)R. Examples: < is antisymmetric, “likes” is not. Exercise: prove this definition of antisymmetric is equivalent to the statement that RR−1  IA. 9/21/2018 (c)2001-2003, Michael P. Frank

Transitivity A relation R is transitive iff (for all a,b,c) (a,b)R  (b,c)R → (a,c)R. A relation is intransitive iff it is not transitive. Some examples: “is an ancestor of” is transitive. “likes” between people is intransitive. “is located within 1 mile of” is… ? 9/21/2018 (c)2001-2003, Michael P. Frank

Totality A relation R:A×B is total if for every aA, there is at least one bB such that (a,b)R. If R is not total, then it is called strictly partial. A partial relation is a relation that might be strictly partial. (Or, it might be total.) In other words, all relations are considered “partial.” 9/21/2018 (c)2001-2003, Michael P. Frank

Functionality A relation R:A×B is functional if, for any aA, there is at most 1 bB such that (a,b)R. “R is functional”  aA: ¬b1≠b2B: aRb1  aRb2. Iff R is functional, then it corresponds to a partial function R:A→B where R(a)=b  aRb; e.g. E.g., The relation aRb :≡ “a + b = 0” yields the function −(a) = b. R is antifunctional if its inverse relation R−1 is functional. Note: A functional relation (partial function) that is also antifunctional is an invertible partial function. R is a total function R:A→B if it is both functional and total, that is, for any aA, there is exactly 1 b such that (a,b)R. I.e., aA: ¬!b: aRb. If R is functional but not total, then it is a strictly partial function. Exercise: Show that iff R is functional and antifunctional, and both it and its inverse are total, then it is a bijective function. 9/21/2018 (c)2001-2003, Michael P. Frank

Lambda Notation The lambda calculus is a formal mathematical language for defining and operating on functions. It is the mathematical foundation of a number of functional (recursive function-based) programming languages, such as LISP and ML. It is based on lambda notation, in which “λa: f(a)” is a way to denote the function f without ever assigning it a specific symbol. E.g., (λx. 3x2+2x) is a name for the function f:R→R where f(x)=3x2+2x. Lambda notation and the “such that” operator “” can also be used to compose an expression for the function that corresponds to any given functional relation. Let R:A×B be any functional relation on A,B. Then the expression (λa: b  aRb) denotes the function f:A→B where f(a) = b iff aRb. E.g., If I write: f :≡ (λa: b  a+b = 0), this is one way of defining the function f(a)=−a. 9/21/2018 (c)2001-2003, Michael P. Frank

Composite Relations Let R:A×B, and S:B×C. Then the composite SR of R and S is defined as: SR = {(a,c) | b: aRb  bSc} Note that function composition fg is an example. Exer.: Prove that R:A×A is transitive iff RR = R. The nth power Rn of a relation R on a set A can be defined recursively by: R0 :≡ IA ; Rn+1 :≡ RnR for all n≥0. Negative powers of R can also be defined if desired, by R−n :≡ (R−1)n. 9/21/2018 (c)2001-2003, Michael P. Frank

§7.2: n-ary Relations An n-ary relation R on sets A1,…,An, written (with signature) R:A1×…×An or R:A1,…,An, is simply a subset R  A1× … × An. The sets Ai are called the domains of R. The degree of R is n. R is functional in the domain Ai if it contains at most one n-tuple (…, ai ,…) for any value ai within domain Ai. 9/21/2018 (c)2001-2003, Michael P. Frank

Relational Databases A relational database is essentially just an n-ary relation R. A domain Ai is a primary key for the database if the relation R is functional in Ai. A composite key for the database is a set of domains {Ai, Aj, …} such that R contains at most 1 n-tuple (…,ai,…,aj,…) for each composite value (ai, aj,…)Ai×Aj×… 9/21/2018 (c)2001-2003, Michael P. Frank

Selection Operators Let A be any n-ary domain A=A1×…×An, and let C:A→{T,F} be any condition (predicate) on elements (n-tuples) of A. Then, the selection operator sC is the operator that maps any (n-ary) relation R on A to the n-ary relation of all n-tuples from R that satisfy C. I.e., RA, sC(R) = {aR | sC(a) = T} 9/21/2018 (c)2001-2003, Michael P. Frank

Selection Operator Example Suppose we have a domain A = StudentName × Standing × SocSecNos Suppose we define a certain condition on A, UpperLevel(name,standing,ssn) :≡ [(standing = junior)  (standing = senior)] Then, sUpperLevel is the selection operator that takes any relation R on A (database of students) and produces a relation consisting of just the upper-level classes (juniors and seniors). 9/21/2018 (c)2001-2003, Michael P. Frank

Projection Operators Let A = A1×…×An be any n-ary domain, and let {ik}=(i1,…,im) be a sequence of indices all falling in the range 1 to n, That is, where 1 ≤ ik ≤ n for all 1 ≤ k ≤ m. Then the projection operator on n-tuples is defined by: 9/21/2018 (c)2001-2003, Michael P. Frank

Projection Example Suppose we have a ternary (3-ary) domain Cars=Model×Year×Color. (note n=3). Consider the index sequence {ik}= 1,3. (m=2) Then the projection P simply maps each tuple (a1,a2,a3) = (model,year,color) to its image: This operator can be usefully applied to a whole relation RCars (a database of cars) to obtain a list of the model/color combinations available. {ik} 9/21/2018 (c)2001-2003, Michael P. Frank

Join Operator Puts two relations together to form a sort of combined relation. If the tuple (A,B) appears in R1, and the tuple (B,C) appears in R2, then the tuple (A,B,C) appears in the join J(R1,R2). A, B, and C here can also be sequences of elements (across multiple fields), not just single elements. 9/21/2018 (c)2001-2003, Michael P. Frank

Join Example Suppose R1 is a teaching assignment table, relating Professors to Courses. Suppose R2 is a room assignment table relating Courses to Rooms,Times. Then J(R1,R2) is like your class schedule, listing (professor,course,room,time). 9/21/2018 (c)2001-2003, Michael P. Frank

§7.3: Representing Relations Some ways to represent n-ary relations: With an explicit list or table of its tuples. With a function from the domain to {T,F}. Or with an algorithm for computing this function. Some special ways to represent binary relations: With a zero-one matrix. With a directed graph. 9/21/2018 (c)2001-2003, Michael P. Frank

Using Zero-One Matrices To represent a binary relation R:A×B by an |A|×|B| 0-1 matrix MR = [mij], let mij = 1 iff (ai,bj)R. E.g., Suppose Joe likes Susan and Mary, Fred likes Mary, and Mark likes Sally. Then the 0-1 matrix representation of the relation Likes:Boys×Girls relation is: 9/21/2018 (c)2001-2003, Michael P. Frank

Zero-One Reflexive, Symmetric Terms: Reflexive, non-reflexive, irreflexive, symmetric, asymmetric, and antisymmetric. These relation characteristics are very easy to recognize by inspection of the zero-one matrix. any- thing any- thing anything anything any- thing any- thing Reflexive: all 1’s on diagonal Irreflexive: all 0’s on diagonal Symmetric: all identical across diagonal Antisymmetric: all 1’s are across from 0’s 9/21/2018 (c)2001-2003, Michael P. Frank

Using Directed Graphs A directed graph or digraph G=(VG,EG) is a set VG of vertices (nodes) with a set EGVG×VG of edges (arcs,links). Visually represented using dots for nodes, and arrows for edges. Notice that a relation R:A×B can be represented as a graph GR=(VG=AB, EG=R). Edge set EG (blue arrows) Matrix representation MR: Graph rep. GR: Joe Susan Fred Mary Mark Sally Node set VG (black dots) 9/21/2018 (c)2001-2003, Michael P. Frank

Digraph Reflexive, Symmetric It is extremely easy to recognize the reflexive/irreflexive/ symmetric/antisymmetric properties by graph inspection.            Reflexive: Every node has a self-loop Irreflexive: No node links to itself Symmetric: Every link is bidirectional Antisymmetric: No link is bidirectional These are asymmetric & non-antisymmetric These are non-reflexive & non-irreflexive 9/21/2018 (c)2001-2003, Michael P. Frank

§7.4: Closures of Relations For any property X, the “X closure” of a set A is defined as the “smallest” superset of A that has the given property. The reflexive closure of a relation R on A is obtained by adding (a,a) to R for each aA. I.e., it is R  IA The symmetric closure of R is obtained by adding (b,a) to R for each (a,b) in R. I.e., it is R  R−1 The transitive closure or connectivity relation of R is obtained by repeatedly adding (a,c) to R for each (a,b),(b,c) in R. I.e., it is 9/21/2018 (c)2001-2003, Michael P. Frank

Paths in Digraphs/Binary Relations A path of length n from node a to b in the directed graph G (or the binary relation R) is a sequence (a,x1), (x1,x2), …, (xn−1,b) of n ordered pairs in EG (or R). An empty sequence of edges is considered a path of length 0 from a to a. If any path from a to b exists, then we say that a is connected to b. (“You can get there from here.”) A path of length n≥1 from a to itself is called a circuit or a cycle. Note that there exists a path of length n from a to b in R if and only if (a,b)Rn. 9/21/2018 (c)2001-2003, Michael P. Frank

Simple Transitive Closure Alg. A procedure to compute R* with 0-1 matrices. procedure transClosure(MR:rank-n 0-1 mat.) A := B := MR; for i := 2 to n begin A := A⊙MR; B := B  A {join} end return B {Alg. takes Θ(n4) time} {note A represents Ri, B represents } 9/21/2018 (c)2001-2003, Michael P. Frank

A Faster Transitive Closure Alg. procedure transClosure(MR:rank-n 0-1 mat.) A := MR; for i := 1 to log2 n begin A := A⊙(A+In); {A represents } end return A {Alg. takes only Θ(n3 log n) time!} 9/21/2018 (c)2001-2003, Michael P. Frank

Roy-Warshall Algorithm Uses only Θ(n3) operations! Procedure Warshall(MR : rank-n 0-1 matrix) W := MR for k := 1 to n for i := 1 to n for j := 1 to n wij := wij  (wik  wkj) return W {this represents R*} wij = 1 means there is a path from i to j going only through nodes ≤k 9/21/2018 (c)2001-2003, Michael P. Frank

§7.5: Equivalence Relations An equivalence relation (e.r.) on a set A is simply any binary relation on A that is reflexive, symmetric, and transitive. E.g., = itself is an equivalence relation. For any function f:A→B, the relation “have the same f value”, or =f :≡ {(a1,a2) | f(a1)=f(a2)} is an equivalence relation, e.g., let m=“mother of” then =m = “have the same mother” is an e.r. 9/21/2018 (c)2001-2003, Michael P. Frank

Equivalence Relation Examples “Strings a and b are the same length.” “Integers a and b have the same absolute value.” “Real numbers a and b have the same fractional part.” (i.e., a − b  Z) “Integers a and b have the same residue modulo m.” (for a given m>1) 9/21/2018 (c)2001-2003, Michael P. Frank

Equivalence Classes Let R be any equiv. rel. on a set A. The equivalence class of a, [a]R :≡ { b | aRb } (optional subscript R) It is the set of all elements of A that are “equivalent” to a according to the eq.rel. R. Each such b (including a itself) is called a representative of [a]R. Since f(a)=[a]R is a function of a, any equivalence relation R can be defined using aRb :≡ “a and b have the same f value”, given f. 9/21/2018 (c)2001-2003, Michael P. Frank

Equivalence Class Examples “Strings a and b are the same length.” [a] = the set of all strings of the same length as a. “Integers a and b have the same absolute value.” [a] = the set {a, −a} “Real numbers a and b have the same fractional part (i.e., a − b  Z).” [a] = the set {…, a−2, a−1, a, a+1, a+2, …} “Integers a and b have the same residue modulo m.” (for a given m>1) [a] = the set {…, a−2m, a−m, a, a+m, a+2m, …} 9/21/2018 (c)2001-2003, Michael P. Frank

Partitions A partition of a set A is the set of all the equivalence classes {A1, A2, … } for some equivalence relation on A. The Ai’s are all disjoint and their union = A. They “partition” the set into pieces. Within each piece, all members of that set are equivalent to each other. 9/21/2018 (c)2001-2003, Michael P. Frank

§7.6: Partial Orderings A relation R on A is called a partial ordering or partial order iff it is reflexive, antisymmetric, and transitive. We often use a symbol looking something like ≼ (or analogous shapes) for such relations. Examples: ≤, ≥ on real numbers, ,  on sets. Another example: the divides relation | on Z+. Note it is not necessarily the case that either a≼b or b≼a. A set A together with a partial order ≼ on A is called a partially ordered set or poset and is denoted (A, ≼). 9/21/2018 (c)2001-2003, Michael P. Frank

Posets as Noncyclical Digraphs There is a one-to-one correspondence between posets and the reflexive+transitive closures of noncyclical digraphs. Noncyclical: Containing no directed cycles. Example: consider the poset ({0,…,10},|) Its minimal digraph: 2 4 8 3 6 1 5 9 7 10 9/21/2018 (c)2001-2003, Michael P. Frank

More to come… More slides on partial orderings to be added in the future… 9/21/2018 (c)2001-2003, Michael P. Frank