1. Trang chủ
  2. » Giáo án - Bài giảng

Chapter 4 Sets and Functions Discrete Structures for Computer Science (CO1007)

40 497 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Cấu trúc

  • Properties of Relations

  • Combining Relations

  • Representing Relations

  • Closures of Relations

  • Types of Relations

  • Homeworks

Nội dung

Relations Nguyen An Khuong, Huynh Tuong Nguyen Chapter Relations Contents Properties of Relations Discrete Structures for Computer Science (CO1007) on Ngày tháng 11 năm 2016 Combining Relations Representing Relations Closures of Relations Types of Relations Homeworks Nguyen An Khuong, Huynh Tuong Nguyen Faculty of Computer Science and Engineering University of Technology, VNU-HCM 4.1 Contents Relations Nguyen An Khuong, Huynh Tuong Nguyen Properties of Relations Contents Properties of Relations Combining Relations Combining Relations Representing Relations Closures of Relations Representing Relations Types of Relations Homeworks Closures of Relations Types of Relations Homeworks 4.2 Relations Introduction Nguyen An Khuong, Huynh Tuong Nguyen Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations Homeworks Function? 4.3 Relations Relation Nguyen An Khuong, Huynh Tuong Nguyen Definition Contents Let A and B be sets A binary relation (quan hệ hai ngôi) from a set A to a set B is a set Properties of Relations Combining Relations Representing Relations R⊆A×B Closures of Relations Types of Relations Homeworks • Notations: (a, b) ∈ R ←→ aRb • n-ary relations: R ⊂ A1 × A2 × · · · × An 4.4 Relations Example Nguyen An Khuong, Huynh Tuong Nguyen Example Let A = {a, b, c} be the set of students, B = {l, c, s, g, d} be the set of the available optional courses We can have relation R that consists of pairs (x, y), where x is a student enrolled in course y Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations R {(a, l), (a, s), (a, g), (b, c), = Homeworks (b, s), (b, g), (c, l), (c, g)} R a b c l x c x x s x x g x x x 4.5 Functions as Relations Relations Nguyen An Khuong, Huynh Tuong Nguyen Contents Properties of Relations Combining Relations • Is a function a relation? • Yes! • f : A→B Representing Relations Closures of Relations Types of Relations Homeworks R = {(a, b) ∈ A × B | b = f (a)} ⊂ A × B - the graph of f 4.6 Functions as Relations Relations Nguyen An Khuong, Huynh Tuong Nguyen • Is a relation a function? Contents • No Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations Homeworks • Relations are a generalization of functions 4.7 Relations Relations on a Set Nguyen An Khuong, Huynh Tuong Nguyen Definition A relation on the set A is a relation from A to A Contents Example Properties of Relations Let A be the set {1, 2, 3, 4} Which ordered pairs are in the relation R = {(a, b) | a divides b} (a ước số b)? Combining Relations Representing Relations Closures of Relations Types of Relations Solution: Homeworks R = {(1, 1), (1, 2), (1, 3), (1, 4), (2, 2), (2, 4), (3, 3), (4, 4)} R x x x x x x x x 4.8 Properties of Relations Relations Nguyen An Khuong, Huynh Tuong Nguyen Contents Reflexive (phản xạ) Symmetric (đối xứng ) Antisymmetric (phản đối xứng ) Transitive (bắc cầu) xRx, ∀x ∈ A Properties of Relations Combining Relations xRy → yRx, ∀x, y ∈ A Representing Relations Closures of Relations Types of Relations (xRy ∧ yRx) → x = y, ∀x, y ∈ A Homeworks (xRy ∧ yRz) → xRz, ∀x, y, z ∈ A 4.9 Example Relations Nguyen An Khuong, Huynh Tuong Nguyen Example Consider the following relations on {1, 2, 3, 4}: R1 = {(1, 1), (1, 2), (2, 1), (2, 2), (3, 4), (4, 1), (4, 4)}, R2 = {(1, 1), (1, 2), (2, 1)}, R3 = {(1, 1), (1, 2), (1, 4), (2, 1), (2, 2), (3, 3), (4, 1), (4, 4)}, R4 = {(2, 1), (3, 1), (3, 2), (4, 1), (4, 2), (4, 3)}, R5 = {(3, 4)} Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations Homeworks Solution: • Reflexive: R3 • Symmetric: R2 , R3 • Antisymmetric: R4 , R5 • Transitive: R4 , R5 4.10 Equivalence Relations Relations Nguyen An Khuong, Huynh Tuong Nguyen Definition A relation on a set A is called an equivalence relation (quan hệ tương đương ) if it is reflexive, symmetric and transitive Contents Example (1) Properties of Relations The relation R = {(a, b)|a and b are in the same provinces} is an equivalence relation a is equivalent to b and vice versa, denoted a ∼ b Combining Relations Representing Relations Closures of Relations Types of Relations Homeworks Example (2) R = {(a, b) | a = b ∨ a = −b} R is an equivalence relation Example (3) R = {(x, y) | |x − y| < 1} Is R an equivalence relation? 4.26 Relations Example Nguyen An Khuong, Huynh Tuong Nguyen Contents Example (Congruence Modulo m - Đồng dư modulo m) Properties of Relations Combining Relations Let m be a positive integer with m > Show that the relation Representing Relations Closures of Relations R = {(a, b) | a ≡ b (mod m)} Types of Relations Homeworks is an equivalence relation on the set of integers Remark: This is an extremely important example, please read its proof carefully and prove all related properties 4.27 Relations Equivalence Classes Nguyen An Khuong, Huynh Tuong Nguyen Definition Contents Let R be an equivalence relation on the set A The set of all elements that are related to an element a of A is called the equivalence class (lớp tương đương ) of a, denoted by Properties of Relations Combining Relations Representing Relations Closures of Relations [a]R = {s | (a, s) ∈ R} Types of Relations Homeworks Example The equivalence class of “Thủ Đức” for the equivalence relation “in the same provinces” is { “Thủ Đức”, “Gò Vấp”, “Bình Thạnh”, “Quận 10”, .} 4.28 Example Relations Nguyen An Khuong, Huynh Tuong Nguyen Contents Example What are the equivalence classes of 0, 1, 2, for congruence modulo 4? Properties of Relations Combining Relations Representing Relations Closures of Relations Solution: [0]4 = { , −8, −4, 0, 4, 8, } Types of Relations Homeworks [1]4 = { , −7, −3, 1, 5, 9, } [2]4 = { , −6, −2, 2, 6, 10, } [3]4 = { , −5, −1, 3, 7, 11, } 4.29 Equivalence Relations and Partitions Relations Nguyen An Khuong, Huynh Tuong Nguyen Contents Properties of Relations Theorem Combining Relations Let R be an equivalence relation on a set A These statements for elements a and b of A are equivalent: Representing Relations i aRb Closures of Relations Types of Relations Homeworks ii [a] = [b] iii [a] ∩ [b] = ∅ 4.30 Example Relations Nguyen An Khuong, Huynh Tuong Nguyen Example Suppose that S = {1, 2, 3, 4, 5, 6} The collection of sets A1 = {1, 2, 3}, A2 = {4, 5}, and A3 = {6} forms a partition of S, because these sets are disjoint and their union is S Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations Remark Homeworks The equivalence classes of an equivalence relation R on a set S form a partition of S Homework Every partition of a set can be used to form an equivalence relation 4.31 Relations Example Nguyen An Khuong, Huynh Tuong Nguyen Example Divides set of all cities and towns in Vietnam into set of 64 provinces We know that: • there are no provinces with no cities or towns • no city is in more than one province Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations Homeworks • every city is accounted for Definition A partition of a Vietnam is a collection of non-overlapping non-empty subsets of Vietnam (provinces) that, together, make up all of Vietnam 4.32 Relations Relation in a Partition Nguyen An Khuong, Huynh Tuong Nguyen Contents Properties of Relations • We divided based on relation Combining Relations Representing Relations Closures of Relations R = {(a, b)|a and b are in the same Types provinces of Relations Homeworks • “Thủ Đức” is related (equivalent) to “Gò Vấp” • “Đà Lạt” is not related (not equivalent) to ”Long Xuyên” 4.33 Partial Order Relations Relations Nguyen An Khuong, Huynh Tuong Nguyen • Order words such that x comes before y in the dictionary • Schedule projects such that x must be completed before y • Order set of integers, where x < y Contents Properties of Relations Combining Relations Definition Representing Relations A relation R on a set S is called a partial ordering (có thứ tự phận) if it is reflexive, antisymmetric and transitive A set S together with a partial ordering R is called a partially ordered set, or poset (tập có thứ tự phận), and is denoted by (S, R) or (S, ) Closures of Relations Types of Relations Homeworks Example • (Z, ≥) is a poset • Let S a set, (P (S), ⊆) is a poset 4.34 Example Relations Nguyen An Khuong, Huynh Tuong Nguyen Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations Homeworks 4.35 Totally Order Relations Relations Nguyen An Khuong, Huynh Tuong Nguyen Example In the poset (Z+ , |), and are comparable (so sánh được), because | 9, but and are not, because and → That’s why we call it partially ordering Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations Definition Homeworks If (S, ) is a poset and every two elements of S are comparable, S is called a totally ordered (có thứ tự toàn phần) A totally ordered set is also called a chain (dây xích) Example The poset (Z, ≤) is totally ordered 4.36 Relations Maximal & Minimal Elements Nguyen An Khuong, Huynh Tuong Nguyen Definition Contents Properties of Relations • a is maximal (cực đại) in the poset (S, ) if there is no b ∈ S such that a ≺ b • a is minimal (cực tiểu) in the poset (S, b ∈ S such that b ≺ a Combining Relations Representing Relations ) if there is no Closures of Relations Types of Relations Homeworks Example Which elements of the poset ({2, 4, 5, 10, 12, 20, 25}, |) are minimal and maximal? 4.37 Relations Greatest Element& Least Element Nguyen An Khuong, Huynh Tuong Nguyen Definition Contents Properties of Relations • a is the greatest element (lớn nhất) of the poset (S, b a for all b ∈ S • a is the least element (nhỏ nhất) of the poset (S, a ) if Combining Relations Representing Relations ) if b for all b ∈ S Closures of Relations Types of Relations Homeworks The greatest and least element are unique if it exists Example Let S be a set In the poset (P (S), ⊆), the least element is ∅ and the greatest element is S 4.38 Relations Upper Bound & Lower Bound Nguyen An Khuong, Huynh Tuong Nguyen Definition Let A ⊆ (S, ) • If u is an element of S such that a u for all elements a ∈ A, then u is called an upper bound (cận trên) of A a for all elements a ∈ A, then l is called a lower bound (cận dưới) of A • If l is an element of S such that l Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations Homeworks Example • Subset A does not have upper bound and lower bound • The upper bound of B are 20, 40 and the lower bound is 4.39 Problems Relations Nguyen An Khuong, Huynh Tuong Nguyen Contents Properties of Relations Combining Relations I Do as much as possible the Problems in Rosen’s Chapter (7th ed.) and related Problems in Bender and Williamson’s book Representing Relations Closures of Relations Types of Relations Homeworks II Solve all Exercises in the exercises set provided 4.40

Ngày đăng: 29/03/2017, 18:30

TỪ KHÓA LIÊN QUAN