Skip to content

Commit 7267d7f

Browse files
Th0rgalclaudegithub-actions[bot]
authored
fix: allowlist proof-length violations + reduce sorries pass 4 (#1668)
* fix: allowlist 6 proof-length violations from PR #1659 The sorry-reduction pass 3 (PR #1659) introduced several newly proven theorems that exceed the 50-line proof-length limit but were not added to the ALLOWLIST in check_proof_length.py, breaking CI after merge. Theorems added: - compiledStmtStep_letVar (93 lines) - compiledStmtStep_assignVar (147 lines) - compiledStmtStep_return (62 lines) - execStmtList_terminal_core_ite_else_eq (356 lines) - SupportedBodyInterface (54 lines) - legacyCompatibleExternalStmtList_of_compileSetStructMember2_ok (89 lines) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Prove stmtResultMatchesIRExec_compiled_terminal_ite_then and _else Write corrected versions of these theorems that split the condition hypothesis into separate hcondEval/hcondTrue (or hcondFalse) parts, avoiding the OfNat (Option Nat) 0 type error. The proofs use the already-proven execStmtList_terminal_core_ite_{then,else}_eq, stmtResultMatchesIRExec_ir_not_continue_of_terminal_core, and execIRStmts_compiled_terminal_ite_{then,else}_of_irExec helpers. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * chore: auto-refresh derived artifacts * Prove eval_compileRequireFailCond_core_onExpr Proves that compileRequireFailCond produces correct IR for all ExprCompileCore cases. For ge/le expressions, the compilation produces lt/gt IR ops respectively, with correctness shown via case analysis on the comparison predicate. For all other expression types, the proof uses iszero(compileExpr) via a shared helper. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Prove exec_compileStmtList_core with proper Option Nat handling Replaces the sorry in exec_compileStmtList_core with a complete proof handling all 6 StmtListCompileCore cases (nil, letVar, assignVar, require_, return_, stop). The key change from the previously sorry'd code is proper handling of evalExpr returning Option Nat: each case that uses evalExpr first establishes the result is some via eval_compileExpr_core, then case-splits to extract the Nat value. The require_ case uses eval_compileRequireFailCond_core_onExpr (proven in the previous commit) instead of the broken eval_compileRequireFailCond_core whose type signature had = 0 instead of = some 0 for Option Nat. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Prove eval_compileRequireFailCond_core_of_scope (corrected) Adds the scope-based variant of eval_compileRequireFailCond that uses the corrected = some 0 conclusion (instead of the broken = 0 in the TYPESIG_SORRY). Delegates to eval_compileRequireFailCond_core_onExpr via bindingsExactlyMatchIRVarsOnScope_implies_onExpr, following the same pattern as eval_compileExpr_core_of_scope. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Prove exec_compileStmtList_core_extraFuel (remove sorry) Adapts the exec_compileStmtList_core proof to the extraFuel variant by threading extraFuel through all fuel arithmetic. Uses the Option-Nat-correct patterns (rcases on evalIRExpr, eval_compileRequireFailCond_core_onExpr) and the _extraFuel helper lemmas for execIRStmts cons/revert/return. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: disambiguate allowlist entries by capturing dotted theorem names Update THEOREM_RE regex to capture full dot-separated Lean theorem names (e.g. SupportedBodyInterface.helperFreeStepInterface) instead of only the prefix before the first dot. Replace ambiguous allowlist entries with their specific dotted names so each entry targets exactly one proof. Addresses Codex review comment on PR #1668. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Prove exec_compileStmtList_terminal_core_sizeOf_extraFuel (remove last sorry in FunctionBody.lean) Complete proof of the terminal statement list compilation theorem covering all StmtListTerminalCore cases: letVar, assignVar, require_ (pass/fail), return_, stop, and ite (then/else branches). The ITE case required careful fuel arithmetic using sizeOf_spec lemmas with an intermediate subtraction elimination technique to work around omega's limitations with Nat subtraction over many variables. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Prove compiledStmtStep_ite: terminal ITE statement compilation correctness Eliminates one sorry from GenericInduction.lean (49 → 48 sorry warnings). Proves that compiling an ITE statement with terminal branches produces correct IR by bridging source-level execStmt with IR-level block execution via stmtResultMatchesIRExec_compiled_terminal_ite_{then,else}. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * prove compiledStmtStep_require (was TYPESIG_SORRY) Prove the compilation-step theorem for `require` statements by following the pattern from `compiledStmtStep_letVar`. The key insight is that for `ExprCompileCore` conditions, `collectExprNames` only contains variable names (not storage field names), so `scopeNamesPresent (stmtNextScope ...)` can be proved via `scopeNamesPresent_of_included`. Also make `execIRStmts_revertWithMessage_revert` non-private so it can be used cross-file. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * prove stmtListGenericCore_of_{CompileCore,TerminalCore}_of_scopeNamesIncluded Prove both scope-weakening conversion theorems that convert StmtListCompileCore/StmtListTerminalCore proofs into StmtListGenericCore. This eliminates 2 active sorries (48 → 46). Key additions: - scopeNamesIncluded_cons: scope inclusion lifts through cons - stmtListCompileCore_of_scopeNamesIncluded: CompileCore scope weakening - stmtListTerminalCore_of_scopeNamesIncluded: TerminalCore scope weakening These were blocked on compiledStmtStep_require (proven in previous commit) and compiledStmtStep_ite (proven earlier). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * chore: regenerate PrintAxioms.lean and derived artifacts - Regenerate PrintAxioms.lean to reflect visibility/sorry changes: execIRStmts_revertWithMessage_revert (private -> public), exec_compileStmtList_core and _extraFuel (sorry -> proven), exec_compileStmtList_terminal_core_sizeOf_extraFuel (sorry -> proven), compiledStmtStep_ite (sorry -> proven), plus new public theorems. - Update verification_status.json, VERIFICATION_STATUS.md, and check_lean_hygiene.py sorry count (52 -> 46). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude <claude@anthropic.com> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent 297208d commit 7267d7f

8 files changed

Lines changed: 2109 additions & 55 deletions

File tree

Compiler/Proofs/IRGeneration/FunctionBody.lean

Lines changed: 1565 additions & 27 deletions
Large diffs are not rendered by default.

Compiler/Proofs/IRGeneration/GenericInduction.lean

Lines changed: 511 additions & 15 deletions
Large diffs are not rendered by default.

PrintAxioms.lean

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -894,6 +894,7 @@ import Compiler.Proofs.YulGeneration.Equivalence
894894
#print axioms Compiler.Proofs.IRGeneration.FunctionBody.evalExpr_lt_evmModulus_core_onExpr
895895
#print axioms Compiler.Proofs.IRGeneration.FunctionBody.evalExpr_lt_evmModulus_core
896896
#print axioms Compiler.Proofs.IRGeneration.FunctionBody.compileRequireFailCond_core_ok
897+
#print axioms Compiler.Proofs.IRGeneration.FunctionBody.eval_compileRequireFailCond_core_onExpr
897898
#print axioms Compiler.Proofs.IRGeneration.FunctionBody.runtimeStateMatchesIR_setVar_bindValue
898899
#print axioms Compiler.Proofs.IRGeneration.FunctionBody.runtimeStateMatchesIR_setVar_irrelevant
899900
#print axioms Compiler.Proofs.IRGeneration.FunctionBody.compileStmt_core_ok
@@ -915,6 +916,7 @@ import Compiler.Proofs.YulGeneration.Equivalence
915916
#print axioms Compiler.Proofs.IRGeneration.FunctionBody.bindingsExactlyMatchIRVarsOnScope_implies_onExpr
916917
#print axioms Compiler.Proofs.IRGeneration.FunctionBody.eval_compileExpr_core_of_scope
917918
#print axioms Compiler.Proofs.IRGeneration.FunctionBody.evalExpr_lt_evmModulus_core_of_scope
919+
#print axioms Compiler.Proofs.IRGeneration.FunctionBody.eval_compileRequireFailCond_core_of_scope
918920
#print axioms Compiler.Proofs.IRGeneration.FunctionBody.bindingsExactlyMatchIRVarsOnScope_of_included
919921
#print axioms Compiler.Proofs.IRGeneration.FunctionBody.exprBoundNamesPresent_of_scope
920922
#print axioms Compiler.Proofs.IRGeneration.FunctionBody.scopeNamesPresent_of_included
@@ -1008,9 +1010,9 @@ import Compiler.Proofs.YulGeneration.Equivalence
10081010
-- #print axioms Compiler.Proofs.IRGeneration.FunctionBody.evalIRExpr_iszero_of_eval -- private
10091011
-- #print axioms Compiler.Proofs.IRGeneration.FunctionBody.execIRStmt_revertPrefix_continue -- private
10101012
-- #print axioms Compiler.Proofs.IRGeneration.FunctionBody.execIRStmts_revertPrefix_then_revert -- private
1011-
-- #print axioms Compiler.Proofs.IRGeneration.FunctionBody.execIRStmts_revertWithMessage_revert -- private
1012-
-- #print axioms Compiler.Proofs.IRGeneration.FunctionBody.exec_compileStmtList_core -- sorry'd
1013-
-- #print axioms Compiler.Proofs.IRGeneration.FunctionBody.exec_compileStmtList_core_extraFuel -- sorry'd
1013+
#print axioms Compiler.Proofs.IRGeneration.FunctionBody.execIRStmts_revertWithMessage_revert
1014+
#print axioms Compiler.Proofs.IRGeneration.FunctionBody.exec_compileStmtList_core
1015+
#print axioms Compiler.Proofs.IRGeneration.FunctionBody.exec_compileStmtList_core_extraFuel
10141016
-- #print axioms Compiler.Proofs.IRGeneration.FunctionBody.compiled_terminal_ite_body_block_extraFuel_eq -- private
10151017
-- #print axioms Compiler.Proofs.IRGeneration.FunctionBody.compiled_terminal_ite_body_thenBranch_extraFuel_eq -- private
10161018
-- #print axioms Compiler.Proofs.IRGeneration.FunctionBody.compiled_terminal_ite_body_elseBranch_extraFuel_eq -- private
@@ -1036,6 +1038,8 @@ import Compiler.Proofs.YulGeneration.Equivalence
10361038
#print axioms Compiler.Proofs.IRGeneration.FunctionBody.stmtResultMatchesIRExec_ir_not_continue_of_terminal_core
10371039
#print axioms Compiler.Proofs.IRGeneration.FunctionBody.execStmtList_terminal_core_ite_then_eq
10381040
#print axioms Compiler.Proofs.IRGeneration.FunctionBody.execStmtList_terminal_core_ite_else_eq
1041+
#print axioms Compiler.Proofs.IRGeneration.FunctionBody.stmtResultMatchesIRExec_compiled_terminal_ite_then
1042+
#print axioms Compiler.Proofs.IRGeneration.FunctionBody.stmtResultMatchesIRExec_compiled_terminal_ite_else
10391043
#print axioms Compiler.Proofs.IRGeneration.FunctionBody.execIRStmts_compiled_return_core_append_wholeFuel_of_scope
10401044
#print axioms Compiler.Proofs.IRGeneration.FunctionBody.execIRStmts_compiled_stop_core_append_wholeFuel
10411045
-- #print axioms Compiler.Proofs.IRGeneration.FunctionBody.sizeOf_singleton_append_extraFuel_ne_zero -- private
@@ -1051,7 +1055,7 @@ import Compiler.Proofs.YulGeneration.Equivalence
10511055
#print axioms Compiler.Proofs.IRGeneration.FunctionBody.bindingsExactlyMatchIRVarsOnScope_setFreshTemp_irrelevant
10521056
#print axioms Compiler.Proofs.IRGeneration.FunctionBody.compiled_terminal_ite_temp_not_mem_scope
10531057
#print axioms Compiler.Proofs.IRGeneration.FunctionBody.bindingsExactlyMatchIRVarsOnScope_setCompiledTerminalIteTemp_irrelevant
1054-
-- #print axioms Compiler.Proofs.IRGeneration.FunctionBody.exec_compileStmtList_terminal_core_sizeOf_extraFuel -- sorry'd
1058+
#print axioms Compiler.Proofs.IRGeneration.FunctionBody.exec_compileStmtList_terminal_core_sizeOf_extraFuel
10551059
#print axioms Compiler.Proofs.IRGeneration.FunctionBody.stmtResultToSourceResult_matches_irExecResult
10561060

10571061
-- Compiler/Proofs/IRGeneration/GenericInduction.lean
@@ -1146,6 +1150,7 @@ import Compiler.Proofs.YulGeneration.Equivalence
11461150
-- #print axioms Compiler.Proofs.IRGeneration.stmtListScopeDiscipline_scope_names -- private
11471151
#print axioms Compiler.Proofs.IRGeneration.compiledStmtStep_letVar
11481152
#print axioms Compiler.Proofs.IRGeneration.compiledStmtStep_assignVar
1153+
#print axioms Compiler.Proofs.IRGeneration.compiledStmtStep_require
11491154
#print axioms Compiler.Proofs.IRGeneration.compiledStmtStep_return
11501155
#print axioms Compiler.Proofs.IRGeneration.compiledStmtStep_stop
11511156
-- #print axioms Compiler.Proofs.IRGeneration.encodeStorageAt_writeUintSlots_singleton_other -- private
@@ -1209,7 +1214,7 @@ import Compiler.Proofs.YulGeneration.Equivalence
12091214
-- #print axioms Compiler.Proofs.IRGeneration.compiledStmtStep_setStructMember2_singleSlot_of_slotSafety_preserves -- private
12101215
-- #print axioms Compiler.Proofs.IRGeneration.compiledStmtStep_setStorage_of_validateIdentifierShapes -- sorry'd
12111216
-- #print axioms Compiler.Proofs.IRGeneration.terminal_stmtResultMatchesIRExec_implies_stmtStepMatchesIRExec -- private
1212-
-- #print axioms Compiler.Proofs.IRGeneration.compiledStmtStep_ite -- sorry'd
1217+
#print axioms Compiler.Proofs.IRGeneration.compiledStmtStep_ite
12131218
-- #print axioms Compiler.Proofs.IRGeneration.stmtListTouchesUnsupportedContractSurface_append -- private
12141219
-- #print axioms Compiler.Proofs.IRGeneration.stmtListCompileCore_of_requireLiteralGuardFamilyClauses -- private
12151220
-- #print axioms Compiler.Proofs.IRGeneration.foldl_stmtNextScope_requireLiteralGuardFamilyClauses -- private
@@ -1267,6 +1272,9 @@ import Compiler.Proofs.YulGeneration.Equivalence
12671272
#print axioms Compiler.Proofs.IRGeneration.stmtListHelperFreeStepInterface_of_supportedStmtList_of_surface
12681273
#print axioms Compiler.Proofs.IRGeneration.SupportedBodyInterface.helperFreeStepInterface
12691274
-- #print axioms Compiler.Proofs.IRGeneration.exprBoundNamesInScope_of_scopeNamesIncluded -- private
1275+
-- #print axioms Compiler.Proofs.IRGeneration.scopeNamesIncluded_cons -- private
1276+
-- #print axioms Compiler.Proofs.IRGeneration.stmtListCompileCore_of_scopeNamesIncluded -- private
1277+
-- #print axioms Compiler.Proofs.IRGeneration.stmtListTerminalCore_of_scopeNamesIncluded -- private
12701278
-- #print axioms Compiler.Proofs.IRGeneration.stmtListGenericCore_of_stmtListCompileCore_of_scopeNamesIncluded -- private
12711279
-- #print axioms Compiler.Proofs.IRGeneration.stmtListGenericCore_of_stmtListTerminalCore_of_scopeNamesIncluded -- private
12721280
#print axioms Compiler.Proofs.IRGeneration.stmtListGenericCore_of_stmtListCompileCore
@@ -1898,4 +1906,4 @@ import Compiler.Proofs.YulGeneration.Equivalence
18981906
#print axioms Compiler.Proofs.YulGeneration.ir_yul_function_equiv_from_state_of_fuel_goal_and_adequacy
18991907
#print axioms Compiler.Proofs.YulGeneration.ir_yul_function_equiv_from_state_of_stmt_equiv_and_adequacy
19001908
#print axioms Compiler.Proofs.YulGeneration.ir_yul_function_equiv_from_state_of_stmt_equiv
1901-
-- Total: 1767 theorems/lemmas (1179 public, 572 private, 16 sorry'd)
1909+
-- Total: 1775 theorems/lemmas (1189 public, 574 private, 12 sorry'd)

artifacts/verification_status.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
},
66
"proofs": {
77
"axioms": 1,
8-
"sorry": 52
8+
"sorry": 46
99
},
1010
"schema_version": 1,
1111
"tests": {
@@ -33,7 +33,7 @@
3333
"SimpleStorage": 20,
3434
"SimpleToken": 61
3535
},
36-
"proven": 225,
36+
"proven": 231,
3737
"stdlib": 0,
3838
"total": 277
3939
},

docs/VERIFICATION_STATUS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ Also note that the macro-generated `*_semantic_preservation` theorems are not co
158158

159159
**Proof-Only Properties (22 exclusions)**: Internal proof machinery that cannot be tested in Foundry.
160160

161-
52 `sorry` remaining across `Compiler/**/*.lean` and `Verity/**/*.lean` proof modules.
161+
46 `sorry` remaining across `Compiler/**/*.lean` and `Verity/**/*.lean` proof modules.
162162
These are concentrated in the Layer 2 proof modules (`Compiler/Proofs/IRGeneration/`) due to a definition refactor (PR #1639) that added helper-aware interpreter targets. The theorem statements are structurally sound; the tactic proofs are being repaired. Layer 3 proofs and all contract-level specification proofs are fully discharged.
163163

164164
1 documented Lean axiom remains. The Layer 2 body-simulation axiom has been eliminated, and the Layer 3 dispatch bridge is tracked as an explicit theorem hypothesis rather than a Lean axiom.

scripts/check_lean_hygiene.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def main() -> None:
6464
)
6565

6666
# Check 3: Fixed sorry baseline after the merged proof-reduction pass.
67-
expected_sorry = 52
67+
expected_sorry = 46
6868
sorry_count = 0
6969
sorry_locations: list[str] = []
7070
for lean_file in ROOT.rglob("*.lean"):

scripts/check_proof_length.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,8 @@
246246
# because it enumerates the currently admitted singleton heads plus the
247247
# compositional constructors in one place; splitting it would not reduce
248248
# maintenance or proof complexity.
249-
"SupportedStmtList",
249+
"SupportedStmtList.helperSurfaceClosed",
250+
"SupportedStmtList.internalHelperCallNames_nil",
250251
# Tier-2 exact helper-aware singleton mapping-write bridge pieces: one
251252
# theorem exhaustively unfolds the double-mapping compile shape to recover a
252253
# legacy-compatible Yul witness, and the other packages the alternate
@@ -518,6 +519,17 @@
518519
# long due to explicit case-split on helper-surface touching and threading
519520
# of legacy-compatibility through the list induction.
520521
"stmtListGenericWithHelpersAndHelperIR_of_helperFreeStepInterface_and_internalHelperSurfaceStepInterface_and_residualHelperSurfaceStepInterface_and_helperFreeCompiledLegacyCompatible",
522+
# PR #1659 sorry-reduction pass 3 — newly proven step theorems and their
523+
# supporting lemmas. These are mechanical Option-migration-adapted proofs
524+
# that thread source/IR evaluation witnesses through the compiled step
525+
# boundary; decomposition would mostly split bookkeeping away from the
526+
# theorem boundary consumed by the generic induction.
527+
"compiledStmtStep_letVar",
528+
"compiledStmtStep_assignVar",
529+
"compiledStmtStep_return",
530+
"execStmtList_terminal_core_ite_else_eq",
531+
"SupportedBodyInterface.helperFreeStepInterface",
532+
"legacyCompatibleExternalStmtList_of_compileSetStructMember2_ok",
521533
}
522534

523535
# Directories containing proof files to scan.

scripts/property_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@
2626
)
2727
FILE_RE = re.compile(r"^Property(.+)\.t\.sol$")
2828
CONTRACT_NAME_RE = re.compile(r"^[A-Za-z_][A-Za-z0-9_]*$")
29-
THEOREM_NAME_RE = re.compile(r"^[A-Za-z_][A-Za-z0-9_']*$")
29+
THEOREM_NAME_RE = re.compile(r"^[A-Za-z_][A-Za-z0-9_.']*$")
3030
LEAN_IMPORT_RE = re.compile(r"^\s*import\b(?P<body>.*)$")
3131
LEAN_MODULE_NAME_RE = re.compile(r"^[A-Za-z][A-Za-z0-9_.']*$")
3232

3333
# Regex pattern for theorem/lemma declarations with optional Lean prefixes.
3434
THEOREM_RE = re.compile(
3535
r"^\s*(?P<attrs>(?:@\[[^\]]*\]\s*)*)(?P<visibility>(?:(?:private|protected)\s+)*)"
36-
r"(?P<kind>theorem|lemma)\s+(?P<name>[A-Za-z_][A-Za-z0-9_']*)\b"
36+
r"(?P<kind>theorem|lemma)\s+(?P<name>[A-Za-z_][A-Za-z0-9_.']*)\b"
3737
)
3838

3939

0 commit comments

Comments
 (0)