Subgroup of finite index need not be closed in T0 topological group

Statement
It is possible to have a T0 topological group and a subgroup of finite index that is not a closed subgroup of the whole group. In fact, we could choose a subgroup of finite index that is a dense subgroup in the whole group.

Related facts

 * Closed subgroup of finite index implies open
 * Open subgroup implies closed
 * Connected implies no proper open subgroup
 * Compact implies every open subgroup has finite index

Example of 3-adic rationals
Suppose $$G$$ is the group defined as the following subgroup of the additive group of rational numbers:

$$G := \{ \frac{a}{3^n} \mid a,n \in \mathbb{Z}, n \ge 0 \}$$

Let $$H$$ be the subgroup of $$G$$ comprising those elements that can be expressed with even numerators:

$$H := \{ \frac{2a}{3^n} \mid a,n \in \mathbb{Z}, n \ge 0 \}$$

Then:


 * 1) $$G$$ is a T0 topological group: In fact, it is a subgroup of the rationals, hence a metrizable group.
 * 2) $$H$$ is a subgroup of index two in $$G$$: For every $$g \in G$$, either $$g \in H$$ or $$g + 1 \in H$$. Thus, $$H$$ has a coset space of size two, hence has index two.
 * 3) $$H$$ is dense in $$G$$. In particular, it is not closed in $$G$$: For any point $$g$$outside $$H$$, that point plus elements of the form $$1/3^n$$ are all in $$H$$, and these sums approach $$g$$.