挑战
给定T
有限集的子集S={1,2,3,...,n}
,确定是否T
为拓扑。
说明
某个集合的幂 P(S)
集S
是的所有子集的集合S
。一些例子:
S = {}, P(S) = {{}}
S = {1}, P(S) = {{}, {1}}
S = {1,2}, P(S) = {{}, {1}, {2}, {1,2}}
S = {1,2,3}, P(S) = {{}, {1}, {2}, {3}, {1,2}, {1,3}, {2,3}, {1,2,3}}
甲拓扑 T
上的集S
的一个子集P(S)
与以下属性:
{}
在T
和S
在T
- 如果
A
和B
在,T
那么他们的交集A ∩ B
- 如果
A
和B
在,T
那么他们的联合也是A ∪ B
*
*这个定义不是很正确,但是对于有限集却是正确的,对于这个挑战的目的就足够了。实际的公理也将允许无限的并集,但这与有限的情况无关。
细节
- 您可以假定
S = {1,2,...,n}
(或另选S = {0,1,...,n}
)wheren
是出现在中的最大整数T
。 - 输入格式灵活:您可以使用字符串,列表列表或列表集,也可以使用语言可以处理的任何类似格式。您也可以使用集(例如
S = {0,1,...,n}
更方便)。 - 输出必须是trueey或falsey。
- 允许您接受
n
(或替代n+1
或n-1
)作为附加输入。 - 如果使用有序列表,则可以假定集合中的数字已排序。您还可以假定列表具有特定顺序(例如,字典顺序)。
- 当我们表示集合时,可以假定它们的列表表示中没有两个条目相等。
例子
拓扑结构
{{}} over {}
{{},{1}} over {1}
P(S) over S (see in the explanation)
{{},{1},{1,2}} over {1,2}
{{},{1},{2,3},{1,2,3}} over {1,2,3}
{{1}, {1,2,3}, {1,4,5,6}, {1,2,3,4,5,6}, {}, {2,3}, {4,5,6}, {2,3,4,5,6}}
{{}, {1}, {2,3}, {2}, {4,5,6}, {5,6}, {5}, {2,5,6}, {2,5}, {1,5}, {1,2,3,4,5,6}, {1,2,3}, {1,2}, {1,4,5,6}, {1,5,6}, {1,2,5,6}, {2,3,4,5,6}, {2,3,5,6}, {2,3,5}, {1,2,3,5}, {2,4,5,6}, {1,2,5}, {1,2,3,5,6}, {1,2,4,5,6}}
{{}, {1}, {1,2}, {1,2,3}, {1,2,3,4}, {1,2,3,4,5}, {1,2,3,4,5,6}, {1,2,3,4,5,6,7}, {1,2,3,4,5,6,7,8}, {1,2,3,4,5,6,7,8,9}}
{{}, {1}, {1,2,3}, {1,2,3,4,5}, {1,2,3,4,5,6,7}, {1,2,3,4,5,6,7,8,9}}
非拓扑
{{1}} because {} is not contained
{{},{2}} because {1,2} is not contained
{{},{1,2},{2,3}} because the union {1,2,3} is not contained
{{},{1},{1,2},{2,3},{1,2,3}} because the intersection of {1,2} and {2,3} is not contained
{{},{1},{2},{3},{1,2},{2,3},{1,2,3}} because the union of {1} and {3} is not contained
{{}, {1}, {2,3}, {2}, {4,5,6}, {5,6}, {5}, {2,5,6}, {2,5}, {1,5}, {1,2,3,4,5,6}, {1,2,3}, {1,2}, {1,4,5,6}, {1,5,6}, {1,2,5,6}, {2,3,4,5,6}, {2,3,5,6}, {2,3,5}, {2,4,5,6}, {1,2,5}, {1,2,3,5,6}, {1,2,4,5,6}} because {1,2,3,5} is missing
{{}, {1}, {2}, {1,2,3}, {1,2,3,4,5}, {1,2,3,4,5,6,7}, {1,2,3,4,5,6,7,8,9}} because {1,2} is missing
T
是一个集合,所以我认为假设输入中没有子集被重复(即{{}, {1,2}, {1,2}}
无效输入)是合理的。您可以肯定地或否定地在挑战中澄清这一点吗?