<p>I assume from the discussion that you are not actually interested in <em>work space</em> as claimed, but in total space including the size of the input. (Otherwise the trivial $n$-bit encoding scheme can be decoded in logarithmic space.)</p>

<p>Let $k$ be a sufficiently large constant, and consider the following encoding scheme for $X\subseteq\{0,\dots,n-1\}$. Split $\{0,\dots,n-1\}$ into $k$ blocks $B_u$, $u&lt;k$, of size $n/k$ each, and put $X_u=X\cap B_u$. The encoding of $X$ consists of the sequence of the following numbers (written in binary) for each $u&lt;k$:</p>

<ul>
<li><p>the size $s_u=|X_u|$;</p></li>
<li><p>the number corresponding to $X_u$ in the <a href="https://en.wikipedia.org/wiki/Combinatorial_number_system" rel="nofollow noreferrer">combinatorial number system</a> for $s_u$-size subsets.</p></li>
</ul>

<p>As for the size of the encoding, assume $|X|\le n/4$. The numbers $s_u$ take $O(k\log(n/k))$ bits, which will be negligible. We have $s_u\le n/(3k)$ for at least $k/4$ of the $u$'s, in which case the encoding of $X_u$ takes about $H(1/3)\tfrac nk\approx0{.}92n/k$ bits; the remaining $X_u$ take at most $n/k$ bits each. The total is at most $0{.}98n$ bits.</p>

<p>Decoding amounts to deciding which block $i$ goes into, and then figuring out $X_u$; the latter be done easily in space $n/k+O(\log n)$, and one can reuse the space occupied by encodings of the remaining blocks (as long as the total space is at least $2n/k$, which is OK for $k$ large enough).</p>

<p>A better analysis shows that this scheme achieves space essentially $H(1/4)n\approx0{.}812n$: let $p_u=s_u/(n/k)$. Since $|X|/n\le1/4$, the average of $p_u$ over $u&lt;k$ is at most $1/4$. The encoding of $X_u$ takes about $H(p_u)n/k$ bits. Now, the entropy function is concave, hence the average of $H(p_u)$ over $u&lt;k$ is at most $H(1/4)$, and the total space is $H(1/4)n+O(\log n)$. This is optimal up to the $O(\log n)$.</p>

<p>There is of course nothing special about $1/4$. The same argument shows that for any constant $0&lt;c&lt;1/2$, there is an encoding scheme for $\le cn$-size subsets of $\{0,\dots,n-1\}$ that takes $H(c)n+O(\log n)$ bits, and can be decoded in-place. To some extent, it can even be used for $\le s(n)$-size subsets where $s(n)\ll n$, by taking a non-constant number of blocks ($k\ge 2/H(s(n)/n)$ or so), but then the $O(k\log(n/k))$ overhead gets more pronounced, and overtakes the main term when $s(n)$ drops below roughly $\sqrt n$.</p>

CC BY-SA 4.0
2018-05-17T20:58:46.307Z
2018-05-18T07:54:59.517Z
2018-05-18T07:54:59.517Z
Emil Jeřábek
<p>Consider the following decision problem.
Let $q = \sum_{i=0}^{n/4} \binom{n}{i}$ and let $(C_0^n, C_1^n,\dots,C_{q-1}^n)$ be a suitable enumeration of those subsets of $\{0,1,\dots,n-1\}$ that have at most $n/4$ elements.</p>

<blockquote>
  <p><strong>Quarter-Subset Membership</strong><br>
  <em>Input:</em> tuple of non-negative integers $(i,j,n)$ represented in binary<br>
  <em>Question:</em> is $i \in C_j^n$?  </p>
</blockquote>

<p>By picking a "nice" enumeration $(C_i^n)$, can Quarter-Subset Membership be decided by a deterministic Turing machine using no more than $(0.99)n$ bits of workspace, for all large enough $n$?</p>

<hr>

<h2>Discussion</h2>

<p>Let $\log x = \log_2 x$.
It is easy to enumerate all subsets of at most $k$ elements chosen out of $n$ by keeping track of $k$ indices of size $\lceil \log n \rceil$ bits each.
(See also the discussion in Knuth's TAOCP section 7.2.1.3.)
When $k$ is constant this is just $O(\log n)$ bits.
However, if we let $k = cn$ for some constant $c \le 1/4$, then such enumeration schemes use $\Omega(n\log n)$ space.
One can also use an $n$-bit characteristic vector together with a check for the number of bits set.
I'm interested in schemes that beat $n$ bits.</p>

<p>A closely related question is then:</p>

<blockquote>
  <p>For positive $c$ satisfying the inequality $c\log(e(1+c)/c) &lt; 1$, is there a code representing subsets of at most $cn$ elements chosen from $n$ that uses $dn$ bits for some constant $d &lt; 1$, and can be decoded efficiently?</p>
</blockquote>

<p>Note that for large enough $n$,
$$\sum_{i=0}^k\binom{n}{i} \le \left(\binom{n}{k}\right) = \binom{n+k-1}{k},$$
and since
$$\log\binom{n+k-1}{k} \le \log[(e(n+k-1)/k)^k],$$
when $k = cn$ then information-theoretically it follows that $d \le c\log(e(1+c)/c)$ would be achieved with a perfect code.
(This is less than $1$ if $0 &lt; c \le 0.2728$.)
I am therefore looking for a reasonably clean code that can be manipulated without using lots of space.</p>

<p>To obtain a perfect code, one could pick some enumeration of the subsets, run an index through the enumeration in increasing order, and then obtain each combination by decoding the index.
However, decoding such a code when $k \ge \Omega(n/\log n)$ seems to require using at least $n$ bits of space for the enumerations I have looked at, such as via characteristic vectors ordered by increasing Hamming weight and then lexicographically, or via Gray codes.</p>

<p><strike>There might be a way to do this with $o(n)$ space, but I think $(1-\varepsilon)n$ is more likely to be feasible.</strike>
Note that since $\log \binom{n}{cn} \ge cn\log(1/c)$, the information-theoretic lower bound is already $\Omega(n)$ bits, so this really is about whether $(1-\varepsilon)n$ can be achieved for some $\varepsilon &gt; 0$.
A code that is nice enough (but not necessarily perfect) would seem to be enough to answer my question in the affirmative.
It might also be the case that Quarter-Subset Membership can be decided efficiently without explicitly constructing a code.
On the other hand, such an enumeration may not exist: for instance, every sequence of enumerations for values of $n$ might be inherently non-uniform, or it might be the case that any $(1-\varepsilon)n$-bit bound must be breached infinitely often.</p>

CC BY-SA 4.0
2018-05-18T08:01:10.077Z
Your bounds are wasteful. If $0<c<1/2$, then $\log\binom n{cn}=H(c)n-\frac12\log n+O(1)$, and $\log\left(\sum_{i\le cn}\binom ni\right)\le\log\left(n\binom n{cn}\right)\le H(c)n+\frac12\log n+O(1)$. A slightly more careful computation (see e.g. https://mathoverflow.net/q/55585) shows that actually $\sum_{i\le cn}\binom ni=O\left(\binom n{cn}\right)$, hence its log is again $H(c)n-\frac12\log n+O(1)$. Of course, $H(c)<1$ for all $c<1/2$.
Emil Jeřábek
CC BY-SA 4.0
2018-05-19T15:35:22.890Z
@EmilJeřábek good point, so the question can be extended to the more general Half-Subset Membership, and much of the discussion simplified.
András Salamon
<cc.complexity-theory><coding-theory><space-bounded><space-complexity>
Can Quarter-Subset Membership be decided space-efficiently?
András Salamon
# Can Quarter-Subset Membership be decided space-efficiently?

(Asked by: username_0 on 2016-02-26)

Consider the following decision problem.
Let $q = \sum\_{i=0}^{n/4} \binom{n}{i}$ and let $(C\_0^n, C\_1^n,\dots,C\_{q-1}^n)$ be a suitable enumeration of those subsets of $\{0,1,\dots,n-1\}$ that have at most $n/4$ elements.

> **Quarter-Subset Membership**  
> *Input:* tuple of non-negative integers $(i,j,n)$ represented in binary  
> *Question:* is $i \in C\_j^n$?

By picking a "nice" enumeration $(C\_i^n)$, can Quarter-Subset Membership be decided by a deterministic Turing machine using no more than $(0.99)n$ bits of workspace, for all large enough $n$?

---

## Discussion

Let $\log x = \log\_2 x$.
It is easy to enumerate all subsets of at most $k$ elements chosen out of $n$ by keeping track of $k$ indices of size $\lceil \log n \rceil$ bits each.
(See also the discussion in Knuth's TAOCP section 7.2.1.3.)
When $k$ is constant this is just $O(\log n)$ bits.
However, if we let $k = cn$ for some constant $c \le 1/4$, then such enumeration schemes use $\Omega(n\log n)$ space.
One can also use an $n$-bit characteristic vector together with a check for the number of bits set.
I'm interested in schemes that beat $n$ bits.

A closely related question is then:

> For positive $c$ satisfying the inequality $c\log(e(1+c)/c) < 1$, is there a code representing subsets of at most $cn$ elements chosen from $n$ that uses $dn$ bits for some constant $d < 1$, and can be decoded efficiently?

Note that for large enough $n$,
$$\sum\_{i=0}^k\binom{n}{i} \le \left(\binom{n}{k}\right) = \binom{n+k-1}{k},$$
and since
$$\log\binom{n+k-1}{k} \le \log[(e(n+k-1)/k)^k],$$
when $k = cn$ then information-theoretically it follows that $d \le c\log(e(1+c)/c)$ would be achieved with a perfect code.
(This is less than $1$ if $0 < c \le 0.2728$.)
I am therefore looking for a reasonably clean code that can be manipulated without using lots of space.

To obtain a perfect code, one could pick some enumeration of the subsets, run an index through the enumeration in increasing order, and then obtain each combination by decoding the index.
However, decoding such a code when $k \ge \Omega(n/\log n)$ seems to require using at least $n$ bits of space for the enumerations I have looked at, such as via characteristic vectors ordered by increasing Hamming weight and then lexicographically, or via Gray codes.

There might be a way to do this with $o(n)$ space, but I think $(1-\varepsilon)n$ is more likely to be feasible.
Note that since $\log \binom{n}{cn} \ge cn\log(1/c)$, the information-theoretic lower bound is already $\Omega(n)$ bits, so this really is about whether $(1-\varepsilon)n$ can be achieved for some $\varepsilon > 0$.
A code that is nice enough (but not necessarily perfect) would seem to be enough to answer my question in the affirmative.
It might also be the case that Quarter-Subset Membership can be decided efficiently without explicitly constructing a code.
On the other hand, such an enumeration may not exist: for instance, every sequence of enumerations for values of $n$ might be inherently non-uniform, or it might be the case that any $(1-\varepsilon)n$-bit bound must be breached infinitely often.

**Tags:** cc.complexity-theory, coding-theory, space-bounded, space-complexity
> **Comments:**
> **username_1**: Your bounds are wasteful. If $0<c<1/2$, then $\log\binom n{cn}=H(c)n-\frac12\log n+O(1)$, and $\log\left(\sum_{i\le cn}\binom ni\right)\le\log\left(n\binom n{cn}\right)\le H(c)n+\frac12\log n+O(1)$. A slightly more careful computation (see e.g. https://mathoverflow.net/q/55585) shows that actually $\sum_{i\le cn}\binom ni=O\left(\binom n{cn}\right)$, hence its log is again $H(c)n-\frac12\log n+O(1)$. Of course, $H(c)<1$ for all $c<1/2$.  
> **username_0**: @EmilJeřábek good point, so the question can be extended to the more general Half-Subset Membership, and much of the discussion simplified.  

---

## 1 answers

### Answer by username_1 on 2018-05-17. Score: 3 | Accepted answer

I assume from the discussion that you are not actually interested in *work space* as claimed, but in total space including the size of the input. (Otherwise the trivial $n$-bit encoding scheme can be decoded in logarithmic space.)

Let $k$ be a sufficiently large constant, and consider the following encoding scheme for $X\subseteq\{0,\dots,n-1\}$. Split $\{0,\dots,n-1\}$ into $k$ blocks $B\_u$, $u

* the size $s\_u=|X\_u|$;
* the number corresponding to $X\_u$ in the [combinatorial number system](https://en.wikipedia.org/wiki/Combinatorial_number_system) for $s\_u$-size subsets.

As for the size of the encoding, assume $|X|\le n/4$. The numbers $s\_u$ take $O(k\log(n/k))$ bits, which will be negligible. We have $s\_u\le n/(3k)$ for at least $k/4$ of the $u$'s, in which case the encoding of $X\_u$ takes about $H(1/3)\tfrac nk\approx0{.}92n/k$ bits; the remaining $X\_u$ take at most $n/k$ bits each. The total is at most $0{.}98n$ bits.

Decoding amounts to deciding which block $i$ goes into, and then figuring out $X\_u$; the latter be done easily in space $n/k+O(\log n)$, and one can reuse the space occupied by encodings of the remaining blocks (as long as the total space is at least $2n/k$, which is OK for $k$ large enough).

A better analysis shows that this scheme achieves space essentially $H(1/4)n\approx0{.}812n$: let $p\_u=s\_u/(n/k)$. Since $|X|/n\le1/4$, the average of $p\_u$ over $u

There is of course nothing special about $1/4$. The same argument shows that for any constant $0


---

