[{"data":1,"prerenderedAt":4},["ShallowReactive",2],{"65eYJjXced":3},"# Morpho Verity\n\nLean 4 and Verity work for Morpho protocol properties.\n\nThe repository keeps Morpho's upstream Solidity code separate from this\nrepository's Verity work:\n\n| Path | Purpose | License |\n|------|---------|---------|\n| `morpho-blue/` | Morpho Blue upstream submodule. This is the Solidity reference and original test suite. | Morpho upstream license, kept in `morpho-blue/LICENSE` |\n| `morpho-midnight/` | Morpho Midnight upstream submodule. This is the Solidity reference and original test suite. | Morpho upstream license, kept in `morpho-midnight/LICENSE` and `morpho-midnight/LICENSE-SECONDARY` |\n| `morpho-blue-verity/` | Verity implementation, compiler adapter, and Lean proofs for Morpho Blue. | This repository's license |\n| `morpho-midnight-verity/` | Separate Verity and Lean proof package for Morpho Midnight. | This repository's license |\n| `artifacts/`, `config/`, `scripts/`, `docs/` | Reproducibility, parity, CI, and audit-support tooling. | This repository's license |\n\n## Verify Morpho Blue\n\nInstall submodules:\n\n```bash\ngit submodule update --init --recursive\n```\n\nBuild the Verity model and proofs:\n\n```bash\nlake build Morpho.Proofs\n```\n\nThe generated-entrypoint refinement surface is explicit: `Morpho.Proofs`\nbuilds against typed local discipline obligations in\n`morpho-blue-verity/Morpho/Proofs/Disciplines.lean` for generated-body field\nmovement, health guards, and local no-overflow facts. The compact health,\nrefinement, and property theorems are checked by Lean; replacing those\ngenerated-body obligations with smaller internal proofs is still tracked as a\nproof-engineering task.\n\nRun Morpho Blue's original tests against the Verity-compiled artifact:\n\n```bash\n./scripts/run_morpho_blue_parity.sh\n```\n\nThe parity target is pinned in `config/parity-target.json`. The target tuple is\nchecked against `morpho-blue/foundry.toml`. The latest local parity evidence in\nthis workspace is green: both `out/parity/morpho_blue_solidity.log` and\n`out/parity/morpho_blue_verity.log` report 145 passing tests, 0 failures, and 0\nskipped on 2026-06-05 17:54 Europe/Berlin. The mechanical review manifest is\n`MORPH_BLUE_MAPPING.md`.\n\n## Verify Morpho Midnight\n\nBuild the focused Midnight proof package:\n\n```bash\nlake build Midnight.Proofs\n```\n\nBuild the executable artifact for the focused `MidnightRCF` proof model:\n\n```bash\n./scripts/prepare_focused_midnight_artifact.sh\n```\n\nThis emits `artifacts/midnight-focused/MidnightRCF.yul`,\n`MidnightRCF.abi.json`, and `MidnightRCF.bin.raw`. It is executable bytecode for\nthe focused proof model, not a full `IMidnight` implementation.\n\nRun Morpho Midnight's original Foundry tests against upstream Solidity:\n\n```bash\nMORPHO_MIDNIGHT_PARITY_MODE=solidity ./scripts/run_morpho_midnight_parity.sh\n```\n\nBuild the complete Verity-compiled Midnight artifact:\n\n```bash\n./scripts/prepare_midnight_artifact.sh\n```\n\nRun the same original tests against that Verity artifact:\n\n```bash\nMORPHO_MIDNIGHT_PARITY_MODE=verity ./scripts/run_morpho_midnight_parity.sh\n```\n\nThat command expects `artifacts/midnight/Midnight.bin.raw`, or a file supplied\nthrough `MORPHO_MIDNIGHT_ARTIFACT_RAW`. The current local parity evidence is\ngreen: both Solidity and Verity Midnight modes report 373 passing tests, 0\nfailures, and 0 skipped.\n\nMidnight Yul identity is not exact. The checked gate is a fail-closed drift\nmanifest:\n\n```bash\npython3 scripts/report_yul_identity_gap.py --midnight --enforce-configured-gate\n```\n\nThat report compares Solidity `Midnight.sol` `irOptimized` Yul with\n`artifacts/midnight/Midnight.yul` and requires the function-level drift to match\n`config/midnight-yul-identity-unsupported.json`.\n\nThe current Midnight mapping manifest is `MORPHO_MIDNIGHT_MAPPING.md`; validate\nit with:\n\n```bash\npython3 scripts/check_morpho_midnight_mapping.py\n```\n\n## Compare With Morpho Blue\n\nStart from these files:\n\n| Morpho upstream | Verity implementation |\n|-----------------|-----------------------|\n| `morpho-blue/src/Morpho.sol` | `morpho-blue-verity/Morpho/Contract.lean` |\n| `morpho-blue/src/libraries/MathLib.sol` | `morpho-blue-verity/Morpho/Libraries/MathLib.lean` |\n| `morpho-blue/src/libraries/SharesMathLib.sol` | `morpho-blue-verity/Morpho/Libraries/SharesMathLib.lean` |\n| `morpho-blue/src/libraries/ConstantsLib.sol` | `morpho-blue-verity/Morpho/Libraries/ConstantsLib.lean` |\n| `morpho-blue/src/libraries/UtilsLib.sol` | `morpho-blue-verity/Morpho/Libraries/UtilsLib.lean` |\n\n## Compare With Morpho Midnight\n\nStart from these files:\n\n| Morpho upstream | Verity implementation |\n|-----------------|-----------------------|\n| `morpho-midnight/src/Midnight.sol` | `morpho-midnight-verity/Midnight/Contract.lean` |\n| `morpho-midnight/src/interfaces/IMidnight.sol` | `morpho-midnight-verity/Midnight/Proofs/Storage.lean` |\n| `morpho-midnight/src/libraries/ConstantsLib.sol` | constants in `morpho-midnight-verity/Midnight/Contract.lean` and proof files |\n| `morpho-midnight/src/libraries/UtilsLib.sol` | arithmetic lemmas in `morpho-midnight-verity/Midnight/Proofs/Basic.lean` |\n\nProof entrypoints:\n\n- `morpho-blue-verity/Morpho/Proofs/Property1.lean`\n- `morpho-blue-verity/Morpho/Proofs/Property2.lean`\n- `morpho-blue-verity/Morpho/Proofs/Refinement.lean`\n- `morpho-midnight-verity/Midnight/Proofs/RCF.lean`\n- `morpho-midnight-verity/Midnight/Proofs/UnitsAccounting.lean`\n\nOperational docs:\n\n- `MORPH_BLUE_MAPPING.md`\n- `MORPHO_MIDNIGHT_MAPPING.md`\n- `docs/MIDNIGHT_VERITY_PLAN.md`\n- `docs/PARITY_TARGET.md`\n- `docs/CI.md`\n- `docs/TRUST_BOUNDARIES.md`\n- `docs/ARCHITECTURE_REVIEW.md`\n\n## License\n\nThis repository's original work is licensed under MIT. Third-party code keeps\nits original license. In particular, `morpho-blue/` and `morpho-midnight/` are\nMorpho upstream code and are governed by their own license files.\n",1781732214870]