Skip to content

feat(Dictionary/CuckooHashing): rehashing over memory with coins - #2264

Draft
SamuelSchlesinger wants to merge 1 commit into
feat/ram-cuckoo-insertfrom
feat/ram-cuckoo-rehash
Draft

SamuelSchlesinger wants to merge 1 commit into
feat/ram-cuckoo-insertfrom
feat/ram-cuckoo-rehash

Conversation

@SamuelSchlesinger

Copy link
Copy Markdown
Collaborator

worker-claude-015dlg8k-cuckoomem (Claude Code, Opus), for #2205. Third of four stacked PRs on cuckoo hashing over the memory oracle; stacked on #2263.

Change

Dictionary/CuckooHashing/Memory/Rehash.lean: rehashing over Memory with coins.

  • An attempt draws both hash tables with the HashFamily.RandomTable pilot's fill, clears the tables and replays the keys; two fills are a uniform seed (run_fills_bind, via run_fill and uniformOfFintype_prod). After n failed attempts the fallback hashes each key to its position in the first table, under which every insertion settles (isSome_pureReplay_posMap).
  • rehash_spec: the stored model after a rehash follows Scheme.rehashLaw exactly, and every outcome satisfies the invariant.
  • expectedCost_rehash_le: when a uniform seed fails the keys with probability at most a half, a rehash costs at most rehashCost in expectation (geometric attempts plus the fallback). This is the spec-level counterpart of ExecCodeDist.loop_geometric.
  • demonicValid_rehash: every memory call is admissible.

API addition in StateTransition/Randomized.lean (randhop2's lane is idle; posted on #2205): RandomizedSpec.expectedCost_bind_le, bounding p >>= k by a bound on p plus one on the continuation from every outcome. Also Probability.PMF.tsum_pure_mul beside tsum_map_mul/tsum_bind_mul.

Validation

lake build --wfail of the touched modules and their importers; CI runs the full gates.

AI assistance

Written by Claude Code (Opus) as an agent; no human review yet.

🤖 Generated with Claude Code

https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG

A rehash draws fresh hash tables with the RandomTable fill, rebuilds, and
falls back to the position seed after its attempts. Its law is
Scheme.rehashLaw, every outcome satisfies the invariant, and its expected
cost is bounded when attempts fail with probability at most a half. Adds
RandomizedSpec.expectedCost_bind_le and PMF.tsum_pure_mul.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant