在 Mathematica 中生成拓扑空间图

发布于 2024-12-26 12:22:31 字数 119 浏览 3 评论 0原文

我有数学代码来检查集合的集合是否满足拓扑的定义,我现在想以编程方式生成如下图: 拓扑空间

如何做到这一点?

I have mathematica code to check whether a collection of sets satisfies the definition of a topology, I would now like to programmatically generate diagrams like these:
topological spaces

How can this be done?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

不及他 2025-01-02 12:22:31

我不熟悉你的问题,但要从基元创建图表,看起来有点像你粘贴的图表,你可以这样做:

从“基本”案例开始 -

base = {Circle[{-0.4, 0.4}, 0.1], Disk[{0, .125}, 0.05], 
   Text[Style["1", 24], {0, -0.1}],
   Disk[{0.5, .125}, 0.05], Text[Style["2", 24], {0.5, -0.1}], 
   Disk[{1., .125}, 0.05], Text[Style["3", 24], {1., -0.1}], 
   Circle[{.5, 0}, {.9, .5}]};

Graphics[{base}, ImageSize -> 220]

在此处输入图像描述

从此处只需向基本情况添加省略号:

Graphics[{base, Circle[{0, 0}, {.15, .3}]}, ImageSize -> 220]

在此输入图像描述

Graphics[{base, Circle[{0, 0}, {.15, .3}], 
  Circle[{0.5, 0}, {.15, .3}], Circle[{0.25, 0}, {.58, .38}]}, 
 ImageSize -> 220]

在此处输入图像描述

Graphics[{base, Circle[{0.5, 0}, {.15, .3}], 
  Circle[{0.25, 0}, {.58, .38}], Circle[{0.75, 0}, {.58, .38}]}, 
 ImageSize -> 220]

在此处输入图像描述

Graphics[{base, Circle[{0.5, 0}, {.15, .3}], 
  Circle[{1, 0}, {.15, .3}], Red, AbsoluteThickness[6], 
  Line[{{-0.4, -0.5}, {1.4, 0.55}}], 
  Line[{{-0.4, 0.55}, {1.4, -0.5}}]}, ImageSize -> 220]

在此处输入图像描述

Graphics[{base, Circle[{0.25, 0}, {.58, .38}], 
  Circle[{0.75, 0}, {.58, .38}], Red, AbsoluteThickness[6], 
  Line[{{-0.4, -0.5}, {1.4, 0.55}}], 
  Line[{{-0.4, 0.55}, {1.4, -0.5}}]}, ImageSize -> 220]

在此处输入图像描述

请注意,我在调整这些内容时设置了 Frame->True,以便可以看到坐标。

I'm not familiar with your problem but to create diagrams from primitives, that look kind of like the ones you have pasted, you can do this:

start with the "base" case --

base = {Circle[{-0.4, 0.4}, 0.1], Disk[{0, .125}, 0.05], 
   Text[Style["1", 24], {0, -0.1}],
   Disk[{0.5, .125}, 0.05], Text[Style["2", 24], {0.5, -0.1}], 
   Disk[{1., .125}, 0.05], Text[Style["3", 24], {1., -0.1}], 
   Circle[{.5, 0}, {.9, .5}]};

Graphics[{base}, ImageSize -> 220]

enter image description here

From here just add elipses to the base case:

Graphics[{base, Circle[{0, 0}, {.15, .3}]}, ImageSize -> 220]

enter image description here

Graphics[{base, Circle[{0, 0}, {.15, .3}], 
  Circle[{0.5, 0}, {.15, .3}], Circle[{0.25, 0}, {.58, .38}]}, 
 ImageSize -> 220]

enter image description here

Graphics[{base, Circle[{0.5, 0}, {.15, .3}], 
  Circle[{0.25, 0}, {.58, .38}], Circle[{0.75, 0}, {.58, .38}]}, 
 ImageSize -> 220]

enter image description here

Graphics[{base, Circle[{0.5, 0}, {.15, .3}], 
  Circle[{1, 0}, {.15, .3}], Red, AbsoluteThickness[6], 
  Line[{{-0.4, -0.5}, {1.4, 0.55}}], 
  Line[{{-0.4, 0.55}, {1.4, -0.5}}]}, ImageSize -> 220]

enter image description here

Graphics[{base, Circle[{0.25, 0}, {.58, .38}], 
  Circle[{0.75, 0}, {.58, .38}], Red, AbsoluteThickness[6], 
  Line[{{-0.4, -0.5}, {1.4, 0.55}}], 
  Line[{{-0.4, 0.55}, {1.4, -0.5}}]}, ImageSize -> 220]

enter image description here

Note that I set Frame->True while tweaking these so I could see the coordinates.

自控 2025-01-02 12:22:31

为了补充迈克的酷图,这里有一种方法来检查列表的任意有限列表是否是拓扑,即(1)它是否包含空集,(2)基集,(3)在有限交集下封闭,以及(3)在并集下封闭:

topologyQ[x_List] :=
  Intersection[x, #] === # & [
    Union[
      {Union @@ x},
      Intersection @@@ Rest@#,
      Union @@@ #
    ] & @ Subsets @ x
  ]

应用于六个示例

list1 = {{}, {1, 2, 3}};
list2 = {{}, {1}, {1, 2, 3}};
list3 = {{}, {1}, {2}, {1, 2}, {1, 2, 3}};
list4 = {{}, {2}, {1, 2}, {2, 3}, {1, 2, 3}};
list5 = {{}, {2}, {3}, {1, 2, 3}};
list6 = {{}, {1, 2}, {2, 3}, {1, 2, 3}};

,如

topologyQ /@ {list1, list2, list3, list4, list5, list6}

给出

{True, True, True, True, False, False}

编辑1:为了进一步细化公式,请注意,运算符

topoCover := (Union @@ {Union @@@ #, Intersection @@@ Rest@#} &)@Subsets@# &

给出通过采用集合集合的元素的所有并集和交集而获得的集合。如果集合 list 的集合是算子 topoCover 的不动点,那么它就是一个拓扑。因此,我们可以定义一个替代函数来检查 list 是否是拓扑:

 topologyQ2 := (topoCover@# === #) &

如果 list 不是拓扑,则 topoCover 给出 的小超集>list 这是一个拓扑。因此

Complement[topoCover@#,#]&

给出要添加到 list 中以使其成为拓扑的元素。

人们还可以考虑作为拓扑的 list 的最大子集以及要从 list 中删除的元素以对其进行拓扑化。这是通过使用

 maxTopoSubset := (If[{} == #, None, Last@#] &)@(GatherBy[
                     Select[Subsets@#, topologyQ], Length[#] &]) &

Applied 来完成的,例如,当

 maxTopoSubset@list6

我们获得两个拓扑

 {{}, {1, 2}, {1, 2, 3}}, {{}, {2, 3}, {1, 2, 3}}}

时,要删除要删除的元素以从 list 中获取拓扑,可以使用

 removeToTopologize :=  Table[Complement[#, Part[maxTopoSubset@#, i]], {i, 
                            Length@maxTopoSubset@#}] &

using list6 就是从

 removeToTopologize@list6

我们得到的

 {{{2, 3}}, {{1, 2}}}

list6 中删除 {2,3}{1,2}给出一个拓扑。

To complement Mike's cool diagrams, here is a way to check if an arbitrary finite list of lists is a topology, that is, (1) if it contains the empty set, (2) the base set, (3) closed under finite intersections, and (3) closed under union:

topologyQ[x_List] :=
  Intersection[x, #] === # & [
    Union[
      {Union @@ x},
      Intersection @@@ Rest@#,
      Union @@@ #
    ] & @ Subsets @ x
  ]

Applied to the six examples

list1 = {{}, {1, 2, 3}};
list2 = {{}, {1}, {1, 2, 3}};
list3 = {{}, {1}, {2}, {1, 2}, {1, 2, 3}};
list4 = {{}, {2}, {1, 2}, {2, 3}, {1, 2, 3}};
list5 = {{}, {2}, {3}, {1, 2, 3}};
list6 = {{}, {1, 2}, {2, 3}, {1, 2, 3}};

like

topologyQ /@ {list1, list2, list3, list4, list5, list6}

gives

{True, True, True, True, False, False}

EDIT 1: For a further refinement of the formulation, note that the operator

topoCover := (Union @@ {Union @@@ #, Intersection @@@ Rest@#} &)@Subsets@# &

gives the collection obtained by taking all unions and intersections of the elements of a collection of sets. A collection of sets list is a topology if it is a fixed point of the operator topoCover. So one can define an alternative function to check if list is topology:

 topologyQ2 := (topoCover@# === #) &

If list is not a topology, topoCover gives the smalles superset of list which is a topology. So

Complement[topoCover@#,#]&

gives the elements to be added to list to make it a topology.

One can also consider largest subset(s) of list which is a topology and the element(s) to be deleted from list to topologize it. This is done by using

 maxTopoSubset := (If[{} == #, None, Last@#] &)@(GatherBy[
                     Select[Subsets@#, topologyQ], Length[#] &]) &

Applied, for example, to list6 as

 maxTopoSubset@list6

we get the two topologies

 {{}, {1, 2}, {1, 2, 3}}, {{}, {2, 3}, {1, 2, 3}}}

To get the elements to be removed to get a topology from list, one can use

 removeToTopologize :=  Table[Complement[#, Part[maxTopoSubset@#, i]], {i, 
                            Length@maxTopoSubset@#}] &

Using with list6 as

 removeToTopologize@list6

we get

 {{{2, 3}}, {{1, 2}}}

that is, removing {2,3} or {1,2} from list6 gives a topology.

吹泡泡o 2025-01-02 12:22:31

我无法给出数学特定的解决方案,但考虑到在给定的有限集上找到所有拓扑,我可能会分享一些见解。
朴素算法(检查拓扑空间公理的算法)运行时间约为 $2^2^n$。我们将大大减少搜索空间。要实现的关键点是,对于有限集上的每个预序,都有一个拓扑,反之亦然。给定一个拓扑,我们可以创建一个关系,其中 $x \leq y$ iff $y$ 是 $x$ 所属的所有开集的元素。我相信这就是所谓的专业化预购。根据给定的先序,我们可以通过查找上层集合来恢复拓扑。
因此,如果我们可以找到给定集合上的所有预序,我们就可以恢复所有拓扑。查找预订单要容易得多。先序是一种具有传递性和自反性的二元关系。所以搜索空间是$2^n^2$。
还有一些很酷的算法(Floyd-Warshall)可以找到任何给定关系的传递闭包。找到自反闭包也很容易(只需将单位矩阵添加到邻接矩阵表示中)

I wont be able to give a mathematica specific solution however i might share some insight considering finding all the topologies on a given finite set.
The naive algorithm (the one that checks topological space axioms) runtime would be around $2^2^n$. We will reduce the search space considerably. Key point to realize is that for every preorder on a finite set there is a topology and vice versa. Given a topology one can create a relation where $x \leq y$ iff $y$ is element of all the open sets which $x$ belongs to. I believe this is called specialization preorder. From a given preorder one can recover the topology by finding the upper sets.
So if we can find all the preorders on a given set, we can recover all the topologies. Finding preorders is considerably easier. A preorder is a binary relation which is transitive and reflexive. So the search space is $2^n^2$.
There are also cool algorithms (Floyd-Warshall ) to find the transitive closure of any given relation. Finding the reflexive closure is also easy (just add the identity matrix to the adjacency matrix represantation)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文