Fixpoint get_first_None (limit:nat) (s: ENTROPY.stream): nat :=
  match limit with
    | O => O (* bogus *)
    | S limit' =>
      match s O with
        | None => O
        | Some _ => S (get_first_None limit' (fun i => s (S i)))
      end
  end
.

Lemma get_bits_stream_error: forall k s e s', ENTROPY.error e s' = ENTROPY.get_bits k s -> (exists i, (i < k)%nat /\ (forall i', s' i' = match Nat.compare i' i with | Lt => s i' | Eq | Gt => s (S i') end) /\ s i = None /\ (forall i', (i' < i)%nat -> s i' <> None)).