Part III · Precision Types, Hardware & Refinement Ch 12 · 40 min · ProveIt/Ch12.lean

Refinement Mappings & Stuttering Steps

Proving a fast log-structured cache+tombstone KV store behaves identically to a 10-line abstract map.

5-Line Architecture Puzzle · Fast Implementation vs. Simple Spec
-- SpecKV: a trivial function `Key → Option Val`.
-- ImplKV: append-only write log + tombstone deletes + background compaction!
-- Question: Background compaction mutates `ImplKV` in memory, yet changes ZERO
-- user-visible keys. How do we express 'internal optimization step' mathematically?
Socratic Gate · Commit to a Prediction Unanswered · Locks on commit

Suppose `abs : ImplKV → SpecKV` maps any concrete log state to its logical key-value view. When background compaction rewrites `ImplKV` from `impl` to `compact impl`, what equation proves compaction is invisible to callers?

Commuting Diagrams: Keep Specs Tiny, Let Implementations Run Fast

Nobody wants auditors reading 3,000 lines of lock-free ring buffers or LSM compaction logic to understand what get and put mean. Instead, write a 10-line SpecKV that any engineer can eyeball in 30 seconds, define an abstraction function abs : ImplKV → SpecKV (purely for verification—erased or unused at runtime!), and prove that every concrete operation either matches SpecKV or stutters (abs s' = abs s).

⊢ ProveIt/Ch12.lean · Log-Structured KV Refinement & Compaction Stuttering
Step 1 / 1
Lean Infoview Open Goal
Hands-On Exercise (ProveIt/Ch12.lean):

In `ProveIt/Ch12.lean`, prove full `put`/`delete`/`get` refinement and multi-pass compaction stuttering for a concrete KV store.

Finished the Socratic gate, Infoview trace, and playground run?
Record completion in local browser storage to track your 20-unit progress.