Basic Procedures
restart;
with(combinat):
#(1)A procedure to generate a topology from a given subbasis S.
generaTe:=proc(X,S)
local i,O,GT1,GT2,T,B;
B:={};
T:={{}};
for O in S do
GT1:={seq(O intersect S[i],i=1..nops(S))} ; B:=B union GT1;
od;
B:=B union {X};
for O in B do
GT2:={seq(O union B[i],i=1..nops(B))};
B:= B union GT2;
T union B;
end:
#(2)A procedure to check if a given collection over X is Topology or not .
CheckTopology:=proc(T)
local i,O,CT,CuT;
CT:={};
if not`subset`(T,powerset(X)) then false; else
for O in T do
CuT:={seq(O intersect T[i],i=1..nops(T)),seq(O union T[i],i=1..nops(T))};
CT:=CT union CuT;
CT:=CT union {{},X};
evalb(CT=T);
fi;
#A procedure to finds the clopen sets of the topology(T)
CO:=proc(X,T)
local A,W;W:={};
for A in T do
if member(X minus A,T)then W:=W union{A};fi;
W;
#A procedure to obtain the relative topology on a subset of X .
subspace:=proc(A,X,T)
map2(`intersect`,A,T);
#A procedure to chek that if the topology is connected [1].
isConn:=proc(X,T)
evalb(CO(X,T)={X,{}});
#A procedure to find the connected components of a given point .
K:=proc(x,X,T) local i,S,SK; SK:={}; S:=map2(`union`,{x},powerset(X)); for i to nops(S) do if isConn(S[i],subspace(S[i],X,T)) then SK:=SK union S[i];fi; od; SK ; end:
#(i)A procedure to list all topologies on a finite set.
ALLT:=proc(probableT) local T,ALLTOPO;
ALLTOPO:={};
for T in probableT do
if CheckTopology(T)=true then ALLTOPO:=ALLTOPO union {T};else
ALLTOPO:=ALLTOPO;
ALLTOPO;
#(ii)A procedure to list the connected topologies on a finite set X .
AllConnected:=proc( AllTopologies)
local B,T;
for T in AllTopologies do
if CO(X,T)={X,{}} then B:= B union {T}; else B:=B;
B;
end: #(iii)A procedure to find the connected components of a given space.
ALLCC:=proc(X,T) local x,CC; CC:={}; for x in X do CC:=CC union {K(x,X,T)}; od; CC; end:
X:={a};
Y:=powerset(X):
Z:=Y minus{{},X}:
W:=powerset(Z):
probableT:={seq(w union{{},X},w=W)}:
nops(probableT):
AllTopologies:=ALLT(probableT);
print(`the number of topologies is`,nops(AllTopologies),`over a set with `,nops(X),`points`);
Allconnectedtopologies:=AllConnected(AllTopologies);
print(`there are `,nops(Allconnectedtopologies),`connected spaces on a set X with `,nops(X),`points` ):
X:={a,b};
print(`there are `,nops(Allconnectedtopologies),`connected spaces on a set X with `,nops(X),`points` );
X:={a,b,c};
#All connected components;
X:={a,b,c,d};
T:={{},X};
ALLConnected_Components:=ALLCC(X,T);
T:=powerset(X);
T:={{},{a},{a,b},{c,d},{a,c,d},X};