Relations. Relations. Relations. Relations. Relations. Relations on a Set. Discrete Mathematics and its Applications 4/4/2011

Similar documents
Lecture 17 : Equivalence and Order Relations DRAFT

Lecture 16 : Relations and Functions DRAFT


Mathematics for Computer Science/Software Engineering. Notes for the course MSM1F3 Dr. R. A. Wilson

Discrete Mathematics. Hans Cuypers. October 11, 2007

Solutions to In-Class Problems Week 4, Mon.

INTRODUCTORY SET THEORY

Just the Factors, Ma am

Automata and Formal Languages

7.1 RELATIONS AND THEIR PROPERTIES

DATA ANALYSIS II. Matrix Algorithms

A linear combination is a sum of scalars times quantities. Such expressions arise quite frequently and have the form

26 Ideals and Quotient Rings

6.045: Automata, Computability, and Complexity Or, Great Ideas in Theoretical Computer Science Spring, Class 4 Nancy Lynch

Notes on Algebraic Structures. Peter J. Cameron

Reading 13 : Finite State Automata and Regular Expressions

8 Divisibility and prime numbers

Automata Theory. Şubat 2006 Tuğrul Yılmaz Ankara Üniversitesi

Formal Languages and Automata Theory - Regular Expressions and Finite Automata -

C H A P T E R Regular Expressions regular expression

Regular Languages and Finite State Machines

INCIDENCE-BETWEENNESS GEOMETRY

Matrix Algebra. Some Basic Matrix Laws. Before reading the text or the following notes glance at the following list of basic matrix algebra laws.

7 Relations and Functions

6.3 Conditional Probability and Independence

Chapter 3. Cartesian Products and Relations. 3.1 Cartesian Products

Discrete Mathematics & Mathematical Reasoning Chapter 10: Graphs

Midterm Practice Problems

Basic Set Theory. 1. Motivation. Fido Sue. Fred Aristotle Bob. LX Semantics I September 11, 2008

NOTES ON LINEAR TRANSFORMATIONS

Discrete Maths. Philippa Gardner. These lecture notes are based on previous notes by Iain Phillips.

MATH 304 Linear Algebra Lecture 9: Subspaces of vector spaces (continued). Span. Spanning set.

MATRIX ALGEBRA AND SYSTEMS OF EQUATIONS

MATRIX ALGEBRA AND SYSTEMS OF EQUATIONS. + + x 2. x n. a 11 a 12 a 1n b 1 a 21 a 22 a 2n b 2 a 31 a 32 a 3n b 3. a m1 a m2 a mn b m

Graphical degree sequences and realizations

Elements of Abstract Group Theory

Using the ac Method to Factor

1 Introduction to Matrices

Social Media Mining. Graph Essentials

Mathematics Review for MS Finance Students

Lecture 2 Matrix Operations

Math 312 Homework 1 Solutions

Rotation Matrices and Homogeneous Transformations

Zachary Monaco Georgia College Olympic Coloring: Go For The Gold

SYSTEMS OF EQUATIONS AND MATRICES WITH THE TI-89. by Joseph Collison

MAT188H1S Lec0101 Burbulla

Factoring Trinomials: The ac Method

Positional Numbering System

Brief Introduction to Vectors and Matrices

Why? A central concept in Computer Science. Algorithms are ubiquitous.

OPTIMAL DESIGN OF DISTRIBUTED SENSOR NETWORKS FOR FIELD RECONSTRUCTION

Copy in your notebook: Add an example of each term with the symbols used in algebra 2 if there are any.

Data Mining: Algorithms and Applications Matrix Math Review

Algebra I Vocabulary Cards

4. FIRST STEPS IN THE THEORY 4.1. A

Arkansas Tech University MATH 4033: Elementary Modern Algebra Dr. Marcel B. Finan

Warshall s Algorithm: Transitive Closure

I. GROUPS: BASIC DEFINITIONS AND EXAMPLES

Limitations of E-R Designs. Relational Normalization Theory. Redundancy and Other Problems. Redundancy. Anomalies. Example

MATH10040 Chapter 2: Prime and relatively prime numbers

Relational Databases

Matrix Multiplication

December 4, 2013 MATH 171 BASIC LINEAR ALGEBRA B. KITCHENS

Math 223 Abstract Algebra Lecture Notes

Part 2: Community Detection

A Primer on Index Notation

Matrix Representations of Linear Transformations and Changes of Coordinates

Quotient Rings and Field Extensions

Database Constraints and Design

4. How many integers between 2004 and 4002 are perfect squares?

Vector and Matrix Norms

Basic Concepts of Set Theory, Functions and Relations

A Dynamic Programming Approach for Generating N-ary Reflected Gray Code List

TU e. Advanced Algorithms: experimentation project. The problem: load balancing with bounded look-ahead. Input: integer m 2: number of machines

Overview. Essential Questions. Precalculus, Quarter 4, Unit 4.5 Build Arithmetic and Geometric Sequences and Series

This unit will lay the groundwork for later units where the students will extend this knowledge to quadratic and exponential functions.

So let us begin our quest to find the holy grail of real analysis.

13 MATH FACTS a = The elements of a vector have a graphical interpretation, which is particularly easy to see in two or three dimensions.

E3: PROBABILITY AND STATISTICS lecture notes

COMP 378 Database Systems Notes for Chapter 7 of Database System Concepts Database Design and the Entity-Relationship Model

Section 5.3. Section 5.3. u m ] l jj. = l jj u j + + l mj u m. v j = [ u 1 u j. l mj

a 11 x 1 + a 12 x a 1n x n = b 1 a 21 x 1 + a 22 x a 2n x n = b 2.

Cartesian Products and Relations

Chapter 7: Products and quotients

Class One: Degree Sequences

1 Solving LPs: The Simplex Algorithm of George Dantzig

Chapter 13: Basic ring theory

Exercise 1: Relational Model

Class notes Program Analysis course given by Prof. Mooly Sagiv Computer Science Department, Tel Aviv University second lecture 8/3/2007

1 Sets and Set Notation.

Abstract Algebra Cheat Sheet

Adding vectors We can do arithmetic with vectors. We ll start with vector addition and related operations. Suppose you have two vectors

1 Symmetries of regular polyhedra

Approximation Algorithms

Database Design and Normal Forms

Euler Paths and Euler Circuits

Geometric Transformations

Degree Hypergroupoids Associated with Hypergraphs

Notes on Orthogonal and Symmetric Matrices MENU, Winter 2013

Classification of Cartan matrices

Transcription:

Rosen 6 th ed., 8. hips between elements of sets occur in many contexts Example relationships in everyday life: employee and her salary, person and relative, business and it s phone number, etc. In mathematics we study relationships such as those between a positive integer and one that divides it, etc. 2 The most direct way to express a relationship between elements of two sets is to use ordered pairs (binary relations) A binary relation from A to B is a set R of ordered pairs where the first element of each ordered pair comes from A and the second element comes from B. We use the notation a R b to denote that (a, b) R and a a R b to denote that (a, b) R. In mathematics we study relationships such as those between a positive integer and one that divides it, etc. Recall the definition of the Cartesian (Cross) Product: The Cartesian Product of sets A and B, A x B, is the set A x B = {<x,y> : x A and y B}. A relation is just any subset of the CP!! R AxB Ex: A = students; B = courses. R = {(a,b) student a is enrolled in class b} 3 4 Recall the definition of a function: f = {<a,b> : b = f(a), aa and bb} Is every function a relation? Yes, a function is a special kind of relation on a Set from a set A to itself are of special interest A relation on the set A is a relation from A to A In other words, a relation on a set A is a subset of A x A 5 6 (c)2-22, Michael P. Frank

Properties of Properties of Reflexivity: A relation R on AxA is reflexive if for all a A, (a,a) R. Symmetry: A relation R on AxA is symmetric if (x,y) R implies (y,x) R. Anti-symmetry: A relation on AxA is anti-symmetric if (a,b) R, a b implies (b,a) R. Transitivity: A relation on AxA is transitive if (a,b) R and (b,c) R imply (a,c) R. Examples.. 7 8 7.2: n-ary 8.2: n-ary An n-ary relation R on sets A,,A n, written (with signature) R:A A n or R:A,,A n, is simply a subset R A A n. The sets A i are called the domains of R. The degree of R is n. R is functional in the domain A i if it contains at most one n-tuple (, a i, ) for any value a i within domain A i. 9 Relational Databases A relational database is essentially just an n-ary relation R. A domain A i is a primary key when the value of the n-tuple from this domain determines the n-tuple. That is, a domain is a primary key when no two n-tuples in the relation have the same value from this domain. Relational Databases A composite key for the database is a set of domains {A i, A j, } such that R contains at most n-tuple (,a i,,a j, ) for each composite value (a i, a j, )A i A j 2 (c)2-22, Michael P. Frank 2

Selection Operators Selection Operator Example Let A be any n-ary domain A=A A n, and let C:A {T,F} be any condition (predicate) on elements (n-tuples) of A. Then, the selection operator s C 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., RA, s C (R) = {ar s C (a) = T} 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, s UpperLevel is the selection operator that takes any relation R on A (database of students) and produces a relation consisting of just the upperlevel classes (juniors and seniors). 3 4 Projection Operators Let A = A A n be any n-ary domain, and let {i k }=(i,,i m ) be a sequence of indices all falling in the range to n, That is, where i k n for all k m. Then the projection operator on n-tuples P{ ik } : A Ai A im is defined by: P a,..., a ) ( a,..., a ) { i }( k n i im Projection Example Suppose we have a ternary (3-ary) domain Cars=Model Year Color. (note n=3). Consider the index sequence {i k }=,3. (m=2) Then the projection P {i simply maps each tuple k } (a,a 2,a 3 ) = (model,year,color) to its image: ( ai, a ) (, ) (, ) i a a3 model color 2 This operator can be usefully applied to a whole relation RCars (a database of cars) to obtain a list of the model/color combinations available. 5 6 Join Operator Puts two relations together to form a sort of combined relation. If the tuple (A,B) appears in R, and the tuple (B,C) appears in R 2, then the tuple (A,B,C) appears in the join J(R,R 2 ). A, B, and C here can also be sequences of elements (across multiple fields), not just single elements. Join Example Suppose R is a teaching assignment table, relating Professors to Courses. Suppose R 2 is a room assignment table relating Courses to Rooms,Times. Then J(R,R 2 ) is like your class schedule, listing (professor,course,room,time). 7 8 (c)2-22, Michael P. Frank 3

Structured Query Language (SQL) Database query language Used to carry out operations that have been described Queries can be made on multiple tables, multiple fields, etc. Note: SQL uses the SELECT command as a projection rather than a selection operator 8.3 Representing 9 2 8.3: Representing 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. Using Zero-One Matrices To represent a binary relation R:A B by an A B - matrix M R = [m ij ], let m ij = iff (a i,b j )R. E.g., Suppose Joe likes Susan and Mary, Fred likes Mary, and Mark likes Sally. Then the - matrix Susan Mary Sally representation Joe of the relation Fred Likes:Boys Girls relation is: Mark 2 22 Properties of Zero-One Reflexive, Symmetric Reflexivity: A relation R on A A is reflexive if for all a A, (a,a) R. Symmetry: A relation R on AxA is symmetric if (x,y) R implies (y,x) R. Anti-symmetry: A relation on A A is anti-symmetric if (a,b) R implies (b,a) R. Or a = b. 23 Terms: Reflexive, symmetric, and antisymmetric. These relation characteristics are very easy to recognize by inspection of the zero-one matrix. any-thing any- thing Reflexive: all s on diagonal Symmetric: all identical across diagonal Antisymmetric: all s are across from s 24 (c)2-22, Michael P. Frank 4

Using Directed Graphs Digraph Reflexive, Symmetric A directed graph or digraph G=(V G,E G ) is a set V G of vertices (nodes) with a set E G V G V G 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 G R =(V G =AB, E G =R). Matrix representation M R : Graph rep. G R : Mary Joe Fred Mark Susan Joe Fred Mark Sally Edge set E G (blue arrows) Node set V G (black dots) Susan Mary Sally 25 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 26 Properties of Transitivity: A relation on A A is transitive if (a,b) R and (b,c) R imply (a,c) R. Graph?? 8.4 Closures of 27 28 8.4: Closures of Paths in Digraphs/Binary 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 aa. I.e., it is R I A 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 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 n R * R nz 29 A path of length n from node a to b in the directed graph G (or the binary relation R) is a sequence (a,x ), (x,x 2 ),, (x n,b) of n ordered pairs in E G (or R). An empty sequence of edges is considered a path of length 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 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)r n. 3 (c)2-22, Michael P. Frank 5

Simple Transitive Closure Alg. A procedure to compute R * with - matrices. procedure transclosure(m R :rank-n - mat.) A := B := M R ; for i := 2 to n begin A := A M R ; B := B A {join} end {note A represents R i, B represents the - matrix for R*} return B {Alg. takes Θ(n 4 ) time} 8.5 Equivalence 8.6 Partial Orderings 3 32 8.5: Equivalence 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 : {(a,a 2 ) f(a )=f(a 2 )} is an equivalence relation, e.g., let m= mother of then = m = have the same mother is an e.r. 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>) 33 34 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. 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, a, a+, a+2, } Integers a and b have the same residue modulo m. (for a given m>) [a] = the set {, a 2m, a m, a, a+m, a+2m, } 35 36 (c)2-22, Michael P. Frank 6

Partitions 8.6: Partial Orderings A partition of a set A is the set of all the equivalence classes {A, A 2, } for some equivalence relation on A. The A i 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. 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, ). 37 38 (c)2-22, Michael P. Frank 7