Proofs: Cuckoo filter
These are the human proofs of Cuckoo filter, at full length.
The false positive rate of a cuckoo filter full
This proof shows: complexity.
Model. Assume ideal hashing: for a key , the pair is uniform on and independent of the table and of the victim, which depend only on the hashes of other keys, on and on the random choices of the inserts. Fix , the victim and . Write .
Theorem. , where is the mean number of entries in a bucket.
Proof. QUERY returns true only if is in , in or in the victim slot. By the union bound it is enough to bound the three probabilities.
First bucket. Fix . The bucket holds at most fingerprints, so at most values of match one of them. Each has probability , so the probability is at most .
Second bucket. For a fingerprint value and a stored entry , the entry is in bucket and matches only if and , that is by the involution. So the expected number of matching entries is
where the sum is over the stored entries, and the two events are independent. The probability of at least one match is at most this.
Victim. The victim has one fingerprint, matched with probability at most .
Fingerprint size. For the rate to be at most it suffices that , which holds for , and for this is about . The paper uses the simpler estimate .
Time. QUERY reads two buckets of slots and the victim, so it takes time in the worst case on the word RAM. DELETE does the same and may run one insert of the victim. An insert takes time when line L4 succeeds and in the worst case.
A cuckoo filter has no false negatives full
This proof shows: correctness, invariant, termination.
Let be the token of a fingerprint stored in bucket or in the victim slot with bucket , and the token of a key . Let be the multiset of tokens of the stored entries and the multiset of tokens of the copies of keys in . Assume that each DELETE is applied only when has a copy in .
Lemma 1 (alt is an involution). For each and , , and so . Also .
Proof. With , . Since is a power of two and , the value is also below . The token of has the set , the same as for . For a key, by definition.
Lemma 2 (invariant (T)). After each operation, .
Proof. By induction. Line L1 makes both empty. A QUERY changes nothing.
INSERT that returns false at line L2 changes nothing.
INSERT otherwise. gains . Call the fingerprint in hand, with the bucket that it is meant for, the carried entry. At line L3 the carried entry is , whose token is by Lemma 1. We claim that, during the insert, the stored entries together with the carried entry have token multiset . Line L4 or L9 stores the carried entry at or , which keeps its token by Lemma 1. Line L5 changes to or , which keeps the token. Line L7 swaps the carried entry with a stored entry of : the stored part now has and the carried entry is . The carried entry before the swap had token , which is now stored, and the stored entry is now carried, so the multiset is unchanged. Line L8 changes to , which keeps the token. Line L10 stores the carried entry in the victim slot with its bucket. So at the end . Line L10 is reached only when the victim slot is empty, because line L2 returned otherwise, so no victim is overwritten.
DELETE. loses one copy of . If line L14 removes from or , the removed token is by Lemma 1. Line L15 then empties the victim slot and runs lines L4 to L10 on its entry, which keeps the token multiset by the argument for INSERT; the victim slot is empty when line L10 can run, so it is not overwritten. If line L16 clears a victim with , its token is by Lemma 1. In each case loses one copy of . Line L17 is not reached: , so some entry has token . Its fingerprint is and its bucket satisfies , so , and line L14 or L16 finds it.
Theorem. After any sequence of operations that respects the precondition of DELETE, QUERY returns true for each with a copy in , and each operation ends.
Proof. If has a copy in , then by Lemma 2. As at the end of the proof of Lemma 2, the entry with this token has fingerprint and bucket or , in the table or in the victim slot. Line L12 checks exactly these places, so it returns true. Each loop of INSERT runs at most MaxKicks rounds, and DELETE runs at most one such insert, so each operation ends.