Skip to content

Commit 2f19972

Browse files
committed
Add maxStore example and stdlib helpers
1 parent 0ec09a5 commit 2f19972

14 files changed

Lines changed: 914 additions & 669 deletions

File tree

STATUS.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,17 @@ Last updated: 2026-02-09
88
- Keep the repo small and auditable.
99
- Track the external tooling landscape (specs + formal verification).
1010
- Resolve spec aliasing hazards (sequential reads vs. forbid `from = to`).
11+
- Make examples smaller + build an ergonomic EDSL surface (stdlib, macros, patterns).
1112

1213
## In Progress
1314
- First compiler correctness lemma (arith + storage).
1415
- Memory model for ABI return encoding.
1516
- Spec shape for reverts (keep `Spec` minimal, add `SpecR`).
1617
- External landscape refresh (Act/Scribble/Certora/SMTChecker/KEVM).
17-
- Reconcile sequential-read vs old-state transfer specs (aliasing boundary).
18+
- Reconcile sequential-read vs old-state transfer specs (aliasing boundary).
1819
- Decide whether to guard old-state specs with `from ≠ to` or adopt sequential reads by default.
20+
- Supply accounting abstraction (list vs set/dedup semantics).
21+
- EDSL ergonomics: add helpers, notations, and a minimal stdlib for common patterns.
1922

2023
## Recently Done
2124
- Lean -> Yul pipeline with runtime + creation bytecode artifacts.
@@ -35,6 +38,11 @@ Last updated: 2026-02-09
3538
- Added a self-transfer counterexample lemma showing `transferSpecR` cannot hold for `from = to` when `amount > 0`.
3639
- Proved sequential transfer spec is equivalent to old-state spec when `from ≠ to`.
3740
- Added a guarded transfer spec (`transferSpecRNoSelf`) and proof it meets execution when `from ≠ to`.
41+
- Added a counterexample lemma showing list-based supply accounting breaks with duplicates.
42+
- Split `Examples.lean` into multiple focused example modules (store ops, risk, token base, supply, transfer).
43+
- Added a minimal EDSL stdlib (`require`, `unless`, `assert`, `sloadSlot`, `sstoreSlot`, `v`, `n`) to reduce syntax noise.
44+
- Added `sloadVar`/`sstoreVar` helpers to cut boilerplate when using variable slots.
45+
- Added a `maxStore` example (stores max(a,b) into a slot) plus selector + Foundry test.
3846
- Minimal docs frontend and compressed docs.
3947
- Further docs tightening (shorter guide + text).
4048
- External landscape scan (spec languages, model checkers, prover stacks).

docs/research-log.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@
1616
- Added a self-transfer counterexample lemma showing `transferSpecR` cannot hold for `from = to` when `amount > 0`.
1717
- Proved sequential transfer spec is equivalent to old-state spec when `from ≠ to`.
1818
- Added a guarded transfer spec (`transferSpecRNoSelf`) and proof it meets execution when `from ≠ to`.
19+
- Added a small counterexample lemma showing list-based supply accounting breaks with duplicates (motivation for sets/dedup).
20+
- Split `Examples.lean` into multiple focused example modules.
21+
- Added a minimal EDSL stdlib with common helpers (`require`, `unless`, `assert`, slot helpers, var/lit helpers).
22+
- Added `sloadVar`/`sstoreVar` stdlib helpers for variable slot access.
23+
- Added a tiny `maxStore` example (store max(a,b) into a slot) plus selector + Foundry test.
1924
- Refreshed external landscape notes (Act, Scribble, Certora, SMTChecker, KEVM, Kontrol).
2025
- Added selector map artifact (fixed + ABI keccak).
2126
- Fixed Foundry selectors and moved to Shanghai EVM.

research/lean_only_proto/DumbContracts/Compiler.lean

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,17 @@ def exampleEntry4 : EntryPoint :=
120120
selector := 0x49f583e3
121121
returns := false }
122122

123+
def exampleEntry5 : EntryPoint :=
124+
{ name := "maxStore"
125+
args := ["slot", "a", "b"]
126+
body := Lang.Stmt.if_
127+
(Lang.Expr.gt (Lang.Expr.var "a") (Lang.Expr.var "b"))
128+
(Lang.Stmt.sstore (Lang.Expr.var "slot") (Lang.Expr.var "a"))
129+
(Lang.Stmt.sstore (Lang.Expr.var "slot") (Lang.Expr.var "b"))
130+
-- maxStore(uint256,uint256,uint256) -> 0xb61d4088
131+
selector := 0xb61d4088
132+
returns := false }
133+
123134
def healthEntrySet : EntryPoint :=
124135
{ name := "setRisk"
125136
args := ["collateral", "debt", "minHF"]

0 commit comments

Comments
 (0)