restart;
with(combinat): #(1)A procedure to find all possible intersections of a given subbasis(S); Basis:=proc(S) local s,U,B; U:=S; for s in S do U:=U union map(`intersect`,U,s); od; B:=U union {X}; #to add the empty intersection; end: #(2)A procedure used to generate a topology(T) from basis(B); Topology:=proc(B) local b,U,t; U:=Basis(S); for b in Basis(S) do U:=U union map(`union`,U,b); od; t:=U union {{}};#to add the empty union; end: #(3)A procedures to check if (T) is a topology or not; CloseIntersection:=proc(T) local A,U; U:=T; for A in T do U:=U union map(`intersect`,U,A); od; if U=T then U; else CloseIntersection(U); fi; end: CloseUnion:=proc(T) local A,U; U:=T; for A in T do U:=U union map(`union`,U,A); od; if U=T then U; else CloseUnion(U); fi; end:
IsTopology:=proc(T) CloseIntersection(T)=T and CloseUnion(T)=T and member({},T) and member(X,T)and `subset`(T,powerset(X)); end:
#(1)A procedure to check if a given point is a limit point or not;
IsLimitPoint:=proc(x,A,X,T) local i,o,L,Omx,O; O:={}; L:={}; if member(x,X)= true then for i to nops(T) do if (member(x,T[i]))then O:= O union {T[i]}; else O:=O; fi; od; Omx:={seq(O[i] minus {x},i=1..nops(O))}; for o in Omx do if ((o intersect A) <> {}) then L:=L union {x}; else L:={}; break; fi; od; L; else false; fi; end: #(2)A procedure to find limit points of a given subset of X;
LimitPoints:=proc(A,X,T) local x,LI; LI:={}; if `subset`(A,X)= true then for x in X do if IsLimitPoint(x,A,X,T) <> {} then LI:=LI union {x}; else LI:=LI; fi; od; LI; else false ; fi; end: #(3)A procedure to find the closure points of a given subset of X ;
ClosurePoints:=proc(A,X,T) A union LimitPoints(A,X,T); end: #(4)A procedure to find the boundary points of a given subset of X;
BoundaryPoints:=proc(A,X,T) ClosurePoints(A,X,T) intersect ClosurePoints(X minus A,X,T); end: #(5)A procedure to find the interior points of a given subset of X;
InteriorPoints:=proc(A,X,T); ClosurePoints(A,X,T) minus BoundaryPoints(A,X,T); end: #(6) A procedure to find the exterior points of a given subset of X ;
ExteriorPoints:=proc(A,X,T) InteriorPoints(X minus A,X,T); end: #(7)A procedure to find the isolated points of a given subset of X;
IsolatedPoints:=proc(A,X,T) A minus LimitPoints(A,X,T); end: #(8) A Procedure to find the isolated points of a given subset of X by definition ;
IsolatedPoints2:=proc(A,X,T) local O,x,iso; iso:={}; for x in X do for O in T do if( member(x,O) and O intersect A ={x}) then iso:=iso union {x}; fi; od; od; iso; end:
X:={a,b,c,d};
S:={{a},{b},{c},{d}};
B:=Basis(S);
T:=Topology(B);
IsTopology(T);
A:={a,c};
LimitPoints_A:=LimitPoints(A,X,T);
ClosurePoints_A:=ClosurePoints(A,X,T);
BoundaryPoints_A:=BoundaryPoints(A,X,T);
InteriorPoints_A:=InteriorPoints(A,X,T);
ExteriorPoints_A:=ExteriorPoints(A,X,T);
IsolatedPoints_A:=IsolatedPoints(A,X,T);
IsolatedPoints2_A:=IsolatedPoints2(A,X,T);
S:={{}};
Basis(S);
A:={b};
X:={a,b};
S:={{a}};
T:=Topology(T);
S:={{a},{a,c},{c,d}};
A:={a,c,d};