Repository navigation
feat(Dictionary/CuckooHashing): seed-level model, memory layout and lookup - #2262
SamuelSchlesinger wants to merge 2 commits into
Conversation
`StateTransitionSpec.wp charge p Q s` is the weakest precondition of a client of a deterministic specification, under a postcondition that sees the answer, the final state and the total charge. It evaluates operation by operation, composes (`wp_bind`, `wp_mono`), and `wp_iff` characterizes it by the run. It generalizes `Record.wp` of #2228, which is the case of a unit charge (`wp_one_iff`). It sits in a leaf module so that the importers of `StateTransition` do not rebuild. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG (cherry picked from commit aaf6c3c, #2244)
…ookup Scheme.spec models cuckoo hashing as a randomized specification over seeds, with a bounded rehash and a fallback seed; Scheme.dictRefinement refines the dictionary by it, and Scheme.expectedCost_le bounds the expected charge of any client under IsCuckooHashPair through the law of model states. The memory layout stores keys, values, two tables and two hash tables in named fields, and a lookup computes lookupEntry on the replayed tables. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG
|
To resume: implement the regime-switched polynomial / double-tabulation family over |
worker-claude-015dlg8k-cuckoomem(Claude Code, Opus), for #2205 (randomized hops, D10). First of four stacked PRs implementing Pagh and Rodler's cuckoo hashing over the memory oracle (#2262 → #2263 → #2264 → #2265); stacked on #2236.Change
The seed-level model (
Dictionary/CuckooHashing/Model.lean, pure).Scheme.specis cuckoo hashing as aRandomizedSpec: a state holds the seed, the keys in insertion order, the dictionary and a freshness flag; the tables are not stored, they arepureReplayof the keys. An insertion of a new key keeps the seed if the replay still succeeds and otherwise rehashes (Scheme.rehashLaw): up toattemptsuniform seeds, then a fallback seed. Programs over memory are finiteFreeMterms, so the Las Vegas loop cannot run until success; the fallback keeps every operation correct and its probability2^-attemptsper rehash is charged.Scheme.dictRefinement: the dictionary is refined by the model; answers do not depend on the seeds (run_map_dict).Scheme.expectedCost_le: underIsCuckooHashPair(the existing pure analysis, reused unchanged), the expected charge of any admissible client is at mostopBoundper operation. The proof tracks the law of the model state (DistInv): fresh states are uniform on the surviving seeds, stale states have probability at most|keys| · 2^-attempts. A per-stateExpectedAmortizedcertificate cannot giveO(1)(an adversary knowing the seed could pick a failing key), so this is the oblivious argument the answers permit.Layout and lookup over
Memory(Dictionary/CuckooHashing/Memory/Basic.lean). Named fields: count, freshness flag, keys, values, two tables (2^bslots,slotWord= index + 1), two hash tables (Ucells, as in theRandomTablepilot). The abstraction reads aModel; the invariant asks the tables to encodepureReplay. A lookup probes two slots and computeslookupEntry(wp_probe, at most 6 reads;wp_getProg, 7).Also:
Probability.PMF.map_apply_of_support(general, inProbability/PMF/Map.lean), andStateTransition/WP.leanfrom #2244 (aaf6c3cb3, cherry-picked unchanged; it leaves this diff when #2244 lands).Existing notions considered:
pureReplay,lookupEntry,survivingSeeds,IsCuckooHashPairandcuckooWalkRoundsare reused unchanged.Model/Schemeare new because no seed-level randomized specification of cuckoo hashing exists; the WordRAM file keeps the seed in machine memory and does the distributional argument onExecCodeDist.Memory.Progspecifications use #2244'sStateTransitionSpec.wprather than a local predicate.Validation
lake build --wfailof the touched modules and their importers,check_hygiene.py --check-simp; CI runs the full gates. Nosorry, axioms or heartbeat overrides.AI assistance
Written by Claude Code (Opus) as an agent; no human review yet.
🤖 Generated with Claude Code
https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG