Let the answer be f(n,k). We will prove by induction on n+k that
f(n,k)=i=0∑k−1(in).
Case n=k=1 is obvious.
Assume that S is the maximum set of the desired sequences and let T be the set of all binary sequences of length n−1. Define the sets A,B,C as follows:
ABC={a∈T∣there exists b∈S with b=0a, but there is no c∈S with c=1a}={a∈T∣there exists b∈S with b=1a, but there is no c∈S with c=0a}={a∈T∣there exists b,c∈S with b=0a,c=1a}.
Clearly, f(n,k)=∣A∣+∣B∣+2∣C∣. Because we can't choose k bits from the last n−1 bits of the sequences that produce all the binary sequences of length k, we have ∣A∣+∣B∣+∣C∣≤f(n−1,k). Now consider the set C. If ∣C∣≥f(n−1,k−1), we can fix k−1 bits from the last n−1 bits to produce all sequences of length k−1. So because of the definition of C, by fixing these k−1 bits and the first bit, all sequences of length k are produced, which is a contradiction. So we have
f(n,k)=∣A∣+∣B∣+2∣C∣≤f(n−1,k)+f(n−1,k−1).
By induction and using Pascal's identity we get
f(n,k)≤i=0∑k−1(in−1)+i=0∑k−2(in−1)=1+i=1∑k−1(in−1)+i=0∑k−2(in−1)=1+i=1∑k−1((in−1)+(i−1n−1))=(0n)+i=1∑k−1(in)=i=0∑k−1(in).
For the equality example, simply choose all binary sequences with at most k−1 zeros. This way, by fixing any k bits, the sequence with k zeros will never be produced and we're done. ■