160 likes | 275 Views
Module INM175 Discrete Mathematics. Topic 7 Set Theoretic Models. 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
E N D
Module INM175Discrete Mathematics Topic 7 Set Theoretic Models
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.
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.
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 = <V, E, in, out> where V is the set of edges; E is the set of vertices; and in, out: EV 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.)
Reachability Now we can derive from the tuple the relation next, that maps each vertex to those that are ‘one step ahead’, thus next: VV 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 : VV reachable = next+
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)
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: VV ‘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).
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+
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}
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.
Quick Revision of Set Theory the empty set {} or Definition by extensioneg 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)
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} egX = {,{1},{2},{3},{1,2},{1,3},{2,3},{1,2,3}}
Products and Relations Cartesian product (x,y) (XY) (xX) (yY) Relation (XY) = (XY) XY denotes the set of all relations from X to Y i.e. any relation R of signature XY is a subset of XY. If a pair (x,y)R, we may write xRy. Given any relation R: X Y domain domdom R = {xX | y:Y • xRy} range ran cod(R) = {yY | x:X • xRy} inverse -1 (y,x)R-1 (x,y) R
More Relational Operators Given any X’ X image [ _ ]yR[X’] x:X’ • xRy Given any relation S: Y Z composition (x,z)SR y:Y •xRy ySz Given any ZX domain restriction R Z = R (ZY)
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 are reflexive, symmetric and transitive. Partial Orders are reflexive, transitive and antisymmetric. Strict Orders are irreflexive, transitive and antisymmetric.
• • • • • • • • • X Y F 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