Skip to content

Proof steps: two sets in a row on one map - #1999

Merged
jasisz merged 2 commits into
mainfrom
map-set-set-rules
Dec 2, 2026
Merged

jasisz merged 2 commits into
mainfrom
map-set-set-rules

Conversation

@jasisz

@jasisz jasisz commented Dec 2, 2026

Copy link
Copy Markdown
Owner

Two new kernel rules for the equality of maps after two writes:

  • map.set.set_same: Map.set(Map.set(m, k, v), k, w) = Map.set(m, k, w)
  • map.set.set_other: when k != k2, Map.set(Map.set(m, k, v), k2, w) = Map.set(Map.set(m, k2, w), k, v)

The producer puts two writes under different keys in a single order, so two maps built from the same writes in a different order end up equal. When it does not know whether two Int keys differ, it splits into cases on it. Lean checks each step against a lemma of the map model (AverMap.step_set_set_same / step_set_set_other). The swap is used only for key types whose order the Lean model states (Int, String, Bool and tuples of them). For record keys the law stays outside the steps (there is a test for this).

This is the step needed to prove that counting is order-independent (bump(bump(c, a), b) = bump(bump(c, b), a), then tally over a reversed list). Part of #1997.

Tests: new laws in tests/fixtures/proof_steps/maps.av, checked by both kernels and by Lean, with mutations that swap the rules. The map differential test covers both rules on the VM, on wasm-gc and in the Lean model. steps_ratchet shows no loss.

Changelog: Proofs can now show that two writes to a map under different keys give the same map in either order, and that a second write under the same key wins.

🤖 Generated with Claude Code

jasisz and others added 2 commits December 2, 2026 11:20
Two new kernel rules for map equality after two writes:
map.set.set_same (the second write under the same key wins) and
map.set.set_other (writes under keys that differ can be put in either
order). The producer puts such writes in one order, so two maps built by
the same writes in another order meet; where it does not know whether two
Int keys differ, it splits on it. Lean checks each step with a lemma of the
map model; the order swap is used only for key types whose order the model
states (Int, String, Bool and tuples of them).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jasisz
jasisz merged commit 353d633 into main Dec 2, 2026
32 checks passed
@jasisz
jasisz deleted the map-set-set-rules branch December 2, 2026 11:05
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