##################################################################### # # Topology # # (Miguel A. Lerma, 7/21/95) # # This program computes de minimum topology containing a given # family of sets and decides if that family is itself a topology. # It also provides several functions to experiment with finite # point set topology. # ##################################################################### # 'empty_oper' returns the result of using a set operation on the # empty family. 'oper' is the operator (`union` or `intersect`), # and U is the universal set. empty_oper := (oper,U) -> if oper=`union` then {} elif oper=`intersect` then U else NULL fi: # Next function returns the family generated by closing a given family # F of subsets of a set U respect to a binary set operator. close_family := proc(F,oper,U) local FF, F1: # In order to avoid an infinite recursive loop # we check the type of the first argument. if not type(F,`set`) then ERROR(`First argument`,F,`should be a set.`) fi: if nops(F)=0 then {empty_oper(oper,U)} # Case of empty family. else F1 := F[1]: # Remove any set and # close the remaining family. FF := close_family(F minus {F1}, oper,U): {F1} union FF union map(oper,FF,F1): # Operate the removed set fi: # with the closed family. end: # Next function computes the topology generated by a family F # of subsets of a given set X. It works by closing the family # respect to intersection and union. topology := (X,F) -> close_family(close_family(F,`intersect`,X),`union`,X): # Next function decides if a family F of subsets of a set X is # a topology. is_topology := (X,F) -> evalb(F = topology(X,F)): # Next function decides if a topology is trivial. is_trivial := (X,T) -> evalb(T = {{},X}): # Next function decides if a topology is discrete. is_discrete := (X,T) -> evalb(nops(T) = 2^nops(X)): # Next function computes the complements of the sets in a family F. complements := (U,F) -> map((x,y) -> `minus`(y,x),F,U): # Next function computes the closed sets in the topology # generated by a family F of subsets of a set X. closed_sets := (X,F) -> complements(X,topology(X,F)): # Next function decides if a given topological space (X,T) is # connected, by checking if it has non trivial open-closed sets. is_connected := (X,T) -> evalb(T intersect complements(X,T) = {{},X}): # Next function computes a topology T restricted to a subset S. restricted_topology := (S,T) -> map(`intersect`,T,S): # Next function computes the interior of a set S in a topological # space (X,T). interior := proc(S,X,T) local A,R: if not type(T,`set`) then ERROR(`Third argument`,T,`should be a set.`) fi: R := {}: for A in T do if A intersect S = A then R := R union A fi: od: R: end: # Next function computes the closure of a set S in a topological # space (X,T). closure := (S,X,T) -> X minus (interior(X minus S,X,T)): # Next function decides if a set S is dense in a topological space (X,T). is_dense := (S,X,T) -> evalb(X = closure(S,X,T)): # Next function computes the boundary of a set S in a topological # space (X,T). boundary := (S,X,T) -> closure(S,X,T) minus interior(S,X,T): # Next function computes the order topology in a set. order_topology := proc(X) local XL: if not type(X,`set`) then ERROR(`Argument`,X,`should be a set.`) fi: if X={} then {{}} else XL := sort(convert(X,`list`)): {X} union order_topology(X minus {XL[nops(XL)]}) fi: end: # Next function checks if a topological space (X,T) is T_0. is_T_0 := proc(X,T) local X1,XX,C,D,x,U: if not type(X,`set`) then ERROR(`First argument`,X,`should be a set.`) fi: if nops(X) <= 1 then true else U := complements(X,T): for x in X do C := closure({x},X,T): # Minimum closed set containing x. # Minimum open set containing x. D := closure({x},X,U): # The only commom point should be x. if not(C intersect D = {x}) then RETURN(false) fi: od: true: fi: end: