Check if a finite space is T0

49 Views Asked by At

Here is an algorithmic problem. The input is a positive integer $n$ and a topology on the set $[1, \dots, n]$ presented as a (randomly ordered) list of the open sets. The output is a binary value signifying whether the given topology is Kolmogorov or not. Is there a "smart" algorithm for this problem (i.e. one which reduces the implied constant and the asymptotic complexity in a mathematically meaningful way)? If in addition the input topology is guaranteed to be irreducible, are there any optimizations then?

I propose a stupid one. For each pair of distinct points (of which there are $\frac{n(n-1)}{2}$), run through all the open sets (of which there are up to $2^n$) and check whether exactly one of them is contained in it.

1

There are 1 best solutions below

0
On

Doesn't improve on the $n(n-1)/2$ or the $2^n$, but possibly a fairly decent Python version:

def pairs(n):
  return [(j,k) for j in range(n) for k  in range(n) if j<k]

def T0(tau, n):
   """Assumes tau is (a basis for) a topology on range(n) = {0,1,...,n-1}"""
  badpairs = pairs(n)
  for V in tau:
    if not badpairs:
      return True
    badpairs = [p for p in badpairs if (p[0] in V)==(p[1] in V)]
  return len(badpairs) == 0