[{"data":1,"prerenderedAt":4},["ShallowReactive",2],{"02RaCthvj2":3},"# Solidity Spec\n\nSolidity Spec is an executable formal model of Solidity in Lean.\nIt follows our work on [oksolc](https://github.com/okcontract/oksolc)'s compiler verification.\n\nThis standalone Lean 4.29.0 package targets **Solidity 0.8.36**, reference\ncompiler **0.8.36+commit.8a079791**, and **Cancun**. `target.json` and\n`Solidity/Target.lean` record the pin; an accepted pragma does not select a\ndifferent semantics. Compiler compatibility is scoped to **`viaIR: true`**,\nwith optimization disabled or enabled at 200 runs. Legacy code generation is\noutside this profile: it can perform implicit aggregate argument copies before\nlater argument effects, whereas the documented IR policy gathers raw arguments\nbefore conversion. This scope is not a proof of general compiler conformance.\n\nThe package contains certificate models and a shared typed core with\ncorrespondence proofs for its statement and certificate interfaces.\nIt is an **incomplete, standalone Solidity formalization**.\n\nRead the [paper](paper/solidity-semantics.pdf)\n([LaTeX source](paper/solidity-semantics.tex)) for the semantics and trust boundary.\nThe [external conformance checks](CONFORMANCE.md) compare selected machine\nexecutions with the pinned compiler and a local Cancun EVM, including explicit\nlegacy-pipeline boundary controls.\n\n| Layer | Authoritative sources | Role |\n| --- | --- | --- |\n| Unified scalar, aggregate and effect core | `Solidity/Core`, `Solidity/Core/Aggregates`, `Solidity/Core/Execution` | Width-indexed values, physical aggregate references, permitted effect orders, scopes, loops and internal function frames |\n| Correspondence proofs | `Solidity/Proofs`, `Solidity/Compatibility/Execution` | Word, typed-expression, condition and stateful evaluators agree with the core; complete call certificates imply core trace preservation |\n| Checked frontend stages | `Solidity/Frontend` | Typed name resolution, rational constants, exact integer conversion, structural elaboration and evaluation preservation; unannotated scalar inference and nominal types |\n| Words and typed contract language | `Contract/Language`, `Contract/Semantics` | Typed finite statements, explicit arithmetic modes, rollback, helpers, logs |\n| Admitted Solidity | `Solidity/Word.lean`, `Checked.lean`, `Function.lean`, `ABI.lean`, `StorageSource.lean` | Expression evaluation, call admission, stateful statements |\n| Layout and initialization | `Solidity/StorageLayout.lean`, `StorageInitialization.lean`, `StorageConstructor.lean` | Packed Boolean fields, word fields, declaration order and constructor execution |\n| Target machine | `Contract/Evm` | Partial Cancun bytecode semantics, gas, storage and deployment frames |\n| Supporting models | `Contract/Yul`, `Contract/Interaction`, `Contract/Export` | Word expressions, world/memory operations and Keccak |\n| Certificate interfaces | `Solidity/Call.lean`, `Contract.lean`, `Storage.lean`, `StorageCreation.lean` | Precise predicates and composition theorems for accepted artifacts |\n| Proof audit | `Contract/Check` | Dependency/axiom inspection for selected theorem contracts |\n\nPaths following the first entry in a cell are relative to the same directory.\nThe resolved machine and certificate interfaces have different input domains.\nConsult the paper for their source-admission assumptions and proof scope.\n\n## Build and check\n\nFrom the root of this package, with the toolchain in `lean-toolchain` installed:\n\n```sh\nmake replay\n```\n\n`make check` builds both libraries and their regression modules with four Lean\nworkers. `make replay` also checks selected theorem statements, transitive axioms\nand definition-source identities, then freshly rechecks the foundation, pilot\nand scalar machine proof closures, one at a time. Set `JOBS` to change build\nparallelism. For an explicit installation, prepend the Lean 4.29.0 `bin`\ndirectory to `PATH` so Lake and the kernel checker share the same toolchain. The package uses Lean's bundled `Std` and has no external Lean\npackage dependencies. The manifest checks require Python 3's standard library;\nno Zig compiler is required.\n\nTo rebuild the paper with [Tectonic](https://tectonic-typesetting.github.io/):\n\n```sh\nmake paper\n```\n\nThe result is `paper/solidity-semantics.pdf`; intermediate files stay in\n`paper/build/`. Tectonic may download its TeX bundle on the first build.\n\n## Use the model\n\nUse `import Solidity.Execution` for lightweight checked execution. Additional\nlaws are in `Solidity.Execution.Proofs`, and admitted-state safety is in\n`Solidity.Execution.Safety`. Compiler-model bridge clients use\n`Solidity.Compatibility.Execution`. The `Solidity` umbrella exports all of\nthese interfaces. Certificate clients also use the exported\n`Compiler.Validation` namespaces.\n\nThe execution machine consumes resolved, typed trees and explicit program\ntables. It models effect-order choices, physical aliases, scopes, loops,\ninternal calls and rollback. Source return, revert and fault remain distinct\nfrom unsupported behavior and interpreter exhaustion. Host-work bounds are\nseparate from EVM gas.\n\nA successful proof checks a statement about this model under its stated\nassumptions. The [safety contract](SAFETY.md) describes the supported\nconfiguration profile; the paper explains the scope of the executable model\nand the interpretation of its certificate interfaces.\n\n## Documentation\n\n- [Semantic contract](SEMANTIC_CONTRACT.md): observations, environmental\n  assumptions, rollback and refinement obligations.\n- [Scalar expressions](SCALARS.md): types, conversion rules and checked input\n  interfaces.\n- [Execution modules](Solidity/Core/Execution) and\n  [aggregate modules](Solidity/Core/Aggregates): executable definitions and proofs.\n- [Safety](SAFETY.md) and [source/target pilots](PILOT.md): theorem statements,\n  premises and the manually paired Cancun fragments.\n- [Theorem contracts](THEOREMS.md): selected roots, expected statements and\n  permitted axioms.\n- [Reference corpus](references/README.md): pinned language and execution\n  references, source identities and licenses.\n- [Release checks](RELEASE.md): build, proof replay and paper reproduction.\n\nSource licensing is [GPL-3.0](LICENSE.txt). Vendored reference snapshots retain\ntheir upstream notices and licenses.\n",1795286046475]