Presentation is loading. Please wait.

Presentation is loading. Please wait.

INM175 Topic 7 1 Module INM175 Discrete Mathematics Topic 7 Set Theoretic Models.

Similar presentations


Presentation on theme: "INM175 Topic 7 1 Module INM175 Discrete Mathematics Topic 7 Set Theoretic Models."— Presentation transcript:

1 INM175 Topic 7 1 Module INM175 Discrete Mathematics Topic 7 Set Theoretic Models

2 INM175 Topic 7 2 Some Useful Constructions in Set Theory (for the modeler) Relational Join_ & _ : ( (X  Y)  (X  Z)  (X  (Y  Z) ) (or direct product) x (R & S) (y, z)  xRy  xSz Corresponding Function (of a relation) cf: (X  Y)  (X  Y) y  cf(R)(x)  xRy The first line in each definition gives the signature of the operator being defined. This includes the number and signatures of its parameters and whether it is to be written infix, prefix or postfix The second line gives its semantics. This consists of the application of the operator to variables universally quantified over its domain and a predicate defining the criteria for membership in the result, subjected to a case analysis if necessary.

3 INM175 Topic 7 3 Modelling LIST in Set Theory Sequence (or list) Seq X : N +  X  s: Seq X dom(s) = [1..#s] Catenation (of lists) _ ^ _ : ((Seq X)  (Seq X))  (Seq X) i  #s  (s^t) i = s i i > #s  (s^t) i = t ( i - #s ) Extract (from list) extract: N +  (Seq X )  (Seq X ) i>j  (extract i s) j = s j i  j  (extract i s) j = s (succ j) The signature in the last definition is said to be Curried (after the logician Haskell B. Curry). Instead of taking two arguments and delivering a result, extract takes one argument and delivers a function that takes the next argument before delivering the final result.

4 INM175 Topic 7 4 Directed Graphs A simple directed graph is just a homogeneous relation. By separately identifying the edges and vertices, we can generalise our model of directed graph (or DG) to the 4-tuple (sequence of four sets), DG = whereV is the set of edges; E is the set of vertices; andin, out: E  V map each edge to the vertices that it goes to and comes from, respectively. (Note that this is the just structure that we used in our ‘airline timetable’ example earlier.)

5 INM175 Topic 7 5 Reachability Now we can derive from the tuple the relation next, that maps each vertex to those that are ‘one step ahead’, thus next: V  V next = in ° out -1 and we can use transitive closure to derive the relation reachable, which maps each vertex to those that can be ‘reached’ from it, along some ‘path’ of contiguous edges, thus: reachable : V  V reachable = next +

6 INM175 Topic 7 6 Directed Acyclic Graphs Cycles in graphs are paths that lead from a vertex to itself. A directed acyclic graph (or DAG) is a DG in which, from every vertex, no path returns to that vertex. Clearly, a DG is acyclic iff no vertex is reachable from itself, that is, its reachability relation and the identity relation on its vertices are disjoint reachable  Id(V) = . The roots of a DAG are those vertices that no edges enter roots:  V roots = dom(next) - ran(next) The leaves of a DAG are those that no edges leave leaves:  V leaves = ran(next) - dom(next)

7 INM175 Topic 7 7 Forests and Trees We can also read a DAG backwards, by deriving from its 4-tuple the relation that maps each vertex to its predecessors, thus: pred : V  V pred = out ° in -1 = next -1 A DAG is a forest when no vertex has more than one predecessor, i.e. pred: V  V ‘Family trees’ are forests, because the family has more that one ‘ancestor’! A forest with a single root is called a tree. A DAG is a tree when #roots = 1 The directory structure in your computer is a tree, at the root of which is the name of a ‘volume’ (such as ‘C:\’ in Windows, or ‘\’ in Unix).

8 INM175 Topic 7 8 Adjacency and Connectivity The adjacency relation maps each vertex to those that are ‘one step away’ in either direction. It is the union of next and pred adj: V  V adj = next  pred (think of this as the original graph with the arrowheads removed) The transitive closure of adjaceny gives the relation that maps each vertex to those that are connected to it by paths of any length in either direction connected: V  V connected = adj +

9 INM175 Topic 7 9 Connected Graphs connected is an equivalence relation. (You should check that assertion for yourself!) So the quotient of the set of vertices by connected will partition the set of vertices into equivalence classes, all the vertices in each of which are connected to each other but not to any vertex in any other set. This quotient tells us whether the original graph had any ‘islands’: that is, zones which were entirely disconnected from the rest. A connected graph has no islands, so satisfies the predicate V/connected = {V}

10 INM175 Topic 7 10 Subtyping and Inheritance The definition of directed graph has been extended by adding constraints. Trees are restricted forests, which are restricted directed acyclic graphs, which are restricted directed graphs. If we call the class of all trees TREE, etc., we have TREE  FOREST  DAG  DG and similarly for connected and undirected graphs. These are examples of subtyping, or inheritance, which you will meet much more of in object-oriented design.

11 INM175 Topic 7 11 Quick Revision of Set Theory the empty set{} or  Definition by extension eg A = {1, 2, 3}, B = {5, 12, 13, 3, 2} membership  eg 2  A, 2  B, 5  B non-membership  but 5  A Definition by comprehension{x  X | P(x)} where P is some property that each member of the set X may or may not possess. eg S = {b  B | even(b)} = {2, 12} cardinality  the number of elements in a set eg  = 0,  A = 3,  B = 5 subset  X  Y if and only if every member of X is a member of Y, or formally:  x((x  X)  (x  Y)) proper subset  X  Y  (X  Y)  (X  Y)

12 INM175 Topic 7 12 Some Set Operators  x union  x  (X  Y)  (x  X)  (x  Y) eg A  B = {1,2,3,5,12,13} intersection  x  (X  Y)  (x  X)  (x  Y) eg A  B = {2,3} difference-x  (X-Y)  (x  X)  (x  Y) eg A-B = {1} and B-A = {5, 12, 13} complement the difference between a set and the current Universe of Discourse eg S = B-S = {5, 13, 3} powerset  X = {s | s  X} eg  X = { ,{1},{2},{3},{1,2},{1,3},{2,3},{1,2,3}}

13 INM175 Topic 7 13 Products and Relations Cartesian product  (x,y)  (X  Y)  (x  X)  (y  Y) Relation  (X  Y) =  (X  Y ) X  Y denotes the set of all relations from X to Y i.e. any relation R of signature X  Y is a subset of X  Y. If a pair (x,y)  R, we may write xRy. Given any relation R: X  Y domaindomdom R = {x  X |  y:Y xRy} range ran cod(R) = {y  Y |  x:X xRy } inverse -1 (y,x)  R -1  (x,y)  R

14 INM175 Topic 7 14 More Relational Operators Given any X’  X image[ _ ]y  R[X’]   x  X’ xRy Given any relation S: Y  Z composition  (x,z)  S  R   y:Y xRy  ySz Given any Z  X domain restriction  R  Z = R  (Z  Y)

15 INM175 Topic 7 15 Properties of Relations Given a set X and a relation R: X  X, R is Reflexive if  x:X xRx Irreflexive if  x:X¬ xRx i.e. R  (Id X) =  Symmetric if  x,y:X xRy  yRx Antisymmetric if  x,y:X xRy  yRx  x=y Transitive if  x,y,z:X xRy  yRz  xRz Some Special Relations and their properties Equivalence relations arereflexive, symmetric and transitive. Partial Orders are reflexive, transitive and antisymmetric. Strict Orders are irreflexive, transitive and antisymmetric.

16 INM175 Topic 7 16 Functions A relation F: X  Y is a function if  x:X  y,z:Y xFy  xFz  y = z We indicate that such a relation is a function by writing F: X  Y If dom F =  X, the function F is total and we write F : X  Y Some Properties of Functions Surjective ( onto ) F [dom X] = Y Injective ( one-to-one ) F -1  Y  X Bijective ( one-to-one and onto ) surjective and injective F XY


Download ppt "INM175 Topic 7 1 Module INM175 Discrete Mathematics Topic 7 Set Theoretic Models."

Similar presentations


Ads by Google