feat(evm): F4c observation and frame lemmas - #7
Draft
Th0rgal wants to merge 2 commits into
Draft
Conversation
A Ξ correspondence proof rarely needs a whole post-state; it needs to know what an instruction can be observed to change, and far more often what it cannot. This adds both halves for the instructions whose effects are localized. Storage locality rests on ordering instances for UInt256 keys: Storage is a Std.TreeMap keyed by compare, but the derived Ord carries no lawfulness instances, so no TreeMap lookup lemma applied to it and no statement about a single key was provable at all. The observations covered are storage key locality (SSTORE is invisible at every other key, and at every key of every other account), logs, memory, RETURN/REVERT halting data, and unrelated accounts. Each instruction gets a step equation plus frame theorems reading the observations off it; the X-level consequences then fix X's result outright through the F4a decomposition theorems.
3 tasks
Keep F4c Observation/Frame lemmas and F4d Block/runUntil from main.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
EvmYul/EVM/Proof/Observation.lean: the observation and frame lemmas a laterΞcorrespondence proof consumes. Builds on theXdecomposition landed in #5 (F4a).A correspondence proof rarely needs a whole post-state — it needs to know what an instruction can be observed to change, and far more often what it cannot. Both halves are supplied for the instructions whose effects are localized:
SSTORE,MSTORE,MSTORE8,LOG0–LOG4,RETURN,REVERT.What's in it
UInt256keys.StorageisStd.TreeMap UInt256 UInt256 compare, but the derivedOrd UInt256carries no lawfulness instances, so noStd.TreeMaplookup lemma applied to it.OrientedCmp/TransCmp/ReflCmp/LawfulEqCmp(plusLawfulBEq) are discharged by reducingcompareonUInt256tocompareon itsFinvalue. Without these, no statement about a single storage key is provable at all.Account.updateStorageis not a plain insert — writing zero erases the key, keeping storage in the canonical form the state root is computed from. Both branches are shown key-local, and both agree withlookupStorageat the key written, which is what makes the distinction invisible to an observer.SSTOREframes.sstorewrites the key, warms(Iₐ, k)and moves the refund counter at once; only the first is observable as storage. HencestorageAt_sstore_self,storageAt_sstore_of_ne_key,storageAt_sstore_of_ne_addr,lookupAccount_sstore_of_ne, andsstore_logSeries/sstore_executionEnv/sstore_σ₀.lookupAccount_setAccount_of_neis the frame that makes "unrelated accounts are untouched" provable;State.storageAtnames the observation anSLOADwould make.afterMachineOp,afterStateOp,afterLogOp) so each frame is proved once per family rather than once per opcode.X-level consequences.X_RETURN/X_REVERTfixX's result outright, with the returned bytes a named slice of the pre-state's memory rather than an existential.xStepAt_*forSSTORE,MSTORE,MSTORE8andLOG0–LOG4give the non-halting iterations.Notes
{ pre with stack := … }rather than an arbitrarypreconstrained bypre.stack = …. That is not cosmetic: with the stack a literal, thepopₙin the operation's implementation reduces and the equation closes byrfl; behind a hypothesis it does not reduce and the proof has to fightX'sCREATE/CALLbranches. The hypothesis form callers want is derived from it.sstore's refund arithmetic is deliberately not pinned down — none of the observations depends on it.sorry, no new axiom.#print axiomson the headline lemmas reports onlypropext,Classical.choice,Quot.sound.Scope stops short of the full
Ξcorrespondence; this is the lemma set F4d/R1 build on.Test plan
lake build EvmYul.EVM.Proof.Observation— greenlake build(full, 1120 jobs) — green#print axiomsonstorageAt_sstore_of_ne_key,storageAt_sstore_of_ne_addr,lookupAccount_sstore_of_ne,storageAt_sstore_self,sstore_logSeries,X_RETURN,X_REVERT,xStepAt_SSTORE,xStepAt_LOG4,afterLogOp_logSeries— standard axioms only