Re: Topology
- To: mathgroup at smc.vnet.net
- Subject: [mg16212] Re: [mg16183] Topology
- From: Daniel Lichtblau <danl>
- Date: Fri, 5 Mar 1999 00:40:46 -0500
- References: <199903020613.BAA05659@smc.vnet.net.>
- Sender: owner-wri-mathgroup at wolfram.com
Vesa-Matti Sarenius wrote:
>
> Hip!
>
> Anyone done this?
>
> T1 is a topology for a set A if
> 1. {} and A are in T1 ({} is the empty set.)
> 2. Any union of members in T1 is in T1
> 3. Any intersection of finitely many members of T1 is in T1
>
> Then an example:
>
> Let A={a,b,c}
> then T1={{},A,{a},{a,b},{c},{a,c}} is a topology for A.
>
> I am trying to do a Mathematica code program to determine for finite
> sets (like A above) whether T1 is a topology.
>
> First I did this:
>
> ElementQ[set_,element_]:=
> Module[{i=0,t=False},While[i<Length[set],i=i+1;
> If[element==set[[i]],t=True,
> t=t]];t]
>
> This checks whether some a is a member of T1
>
> T1={{},{a,b,c},{a}}
> E.g. ElementQ[T1,{}] gives True.
>
> Now I am desperately trying to do:
>
> -TopologyQIntersections
> -TopologyQUnions
>
> two functions which would check the marks 2. and 3. from the definition,
> using the help of ElementQ.
>
> I came up with about nothing. So if anyone have done this or can help me
> otherwise, please do so.
>
> --
> Vesa-Matti Sarenius * - Am I a man or what? - A What!*
> mailto:sarenius at paju.oulu.NOSPAMfi* - What? - Yes, that's right! *
> Koskitie 47 A6 FIN-90500 OULU * * * * *
> http://www.student.oulu.fi/~sarenius * * * * * * * * * * hmmmm! *
> Finland, Europe. Tel. +358-8-342236 fax.+358-8-5305045. * * * * * *
Here is something along the lines you seek. Probably could be improved a
bit re efficiency and/or programming style.
topologyQ[t1_List] := Module[
{tt=t1, pairs,len=Length[t1],unions,isects},
pairs = Flatten[Table[{t1[[j]],t1[[k]]},
{j,len-1},{k,j+1,len}],1];
unions = Map[Union[#[[1]],#[[2]]]&, pairs];
isects = Map[Intersection[#[[1]],#[[2]]]&, pairs];
Union[unions,isects]===Sort[t1] && Cases[t1,{}]=!={}
]
In[24]:= t1 = {{},{a},{a,b},{c},{a,c},{a,b,c}};
In[25]:= topologyQ[t1]
Out[25]= True
Daniel Lichtblau
Wolfram Research
- References:
- Topology
- From: Vesa-Matti Sarenius <sarenius@student.oulu.fi>
- Topology