Commit graph

26 commits

Author SHA1 Message Date
Dan Robinson
6294c5d92e Fix nested function-pointer and storage-path lowering 2026-09-30 06:17:17 -07:00
Dan Robinson
55f3610b90 Optimize Spec Hunt builds, witnesses, and replay runtime 2026-09-29 15:26:27 -07:00
Daniel Robinson
c0cc0749c1
fix(import): parenthesized new callee (((new bytes))(4)) -> import fail_closed (solc succeeds) (#41)
solc 0.8.35 accepts `((new bytes))(4)` — grouping parens around a `new`
expression (Solidity has no 1-tuples) — and runs it as `new bytes(4)`, so
`run()` returns 4. The solc-AST importer failed closed with `unsupported
expression node 'NewExpression'`: the FunctionCall dispatch matched a
NewExpression callee only when it was the DIRECT `expression`, but a
parenthesized callee arrives wrapped in single-element TupleExpression grouping
nodes. It missed the newExpr branch and fell through to the generic Expr.call,
whose tuple collapse re-exposed a bare NewExpression (unsupported as an ordinary
expression).

Peel single-element grouping tuples off the callee before dispatching, so
`((new bytes))(4)` lowers to exactly the same `Expr.newExpr (Ty.bytes) [4]` as
bare `new bytes(4)`. Witness ParenNewBytesLength pins the target: the contract
is accepted and `run()` returns 4.

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-25 00:19:07 -04:00
Daniel Robinson
23adde3454
fix(import): bare ufixed/fixed state var over-rejected -> import fail_closed (solc succeeds) (#40)
A contract declaring a bare fixed-point state var (`ufixed y;` / `fixed y;`) is
accepted by solc 0.8.35 and runs to success, but the solc-AST importer failed
closed with `unsupported Solidity elementary type 'ufixed'`. solc emits the bare
alias name verbatim on the elementary-type node (its typeString is the canonical
`ufixed128x18`), and `type_from_name` only matched the explicit `ufixed<M>x<N>`
form, not the bare alias.

Map bare `ufixed` -> `Ty.ufixed 128 18` and bare `fixed` -> `Ty.fixed 128 18`
(the language-defined aliases). The Lean semantics already model these state
vars (cf. FixedPointBoundary.sol's `ufixed128x18 private plain;`); only the
importer spelling was unmapped. Witness FixedBareStateUfixed pins the target: the
contract is accepted and `run()` returns 1.

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-25 00:08:40 -04:00
Dan Robinson
a402a88943 perf: cut fix-validation wall-clock 2-4x (fast inner gate + parallel suites)
Measured on the 14-core review machine (2026-07-22):
- scripts/fast_inner_gate.sh (NEW): inner-loop build target for fix
  iteration — semantic spine (Interpreter/ABI/Interface/TypeCheck/Checked)
  + cross-cutting law proofs (FuelMonotonicity/AdoptionLaws/Interaction)
  + the repro witness passed as arg. 381s vs >=1587s per iteration
  head-to-head on the same Interface.lean delta. NOT a green-gate
  substitute: the full lake build (all 87 witnesses) still runs once on
  the final candidate. Lean checks every compiled module's proofs, so no
  soundness is lost on intermediate iterations.
- contest/run_samples.py: the ~85 gate checks now run through a
  ThreadPoolExecutor (CONTEST_SAMPLES_JOBS, default 8; =1 restores exact
  serial behavior). Each check wraps its ORIGINAL call expression verbatim
  in a thunk — per-item behavior unchanged, only scheduling. The two
  run_simulated checks monkeypatch hb.run_solidity_lean_observable and
  run strictly after the pool drains. Summary order preserved
  (registration order). Exceptions in a check FAIL that check.
- contest/fingerprint.py: source_ast_hash's chdir window is now under a
  module lock. os.chdir is process-wide; concurrent derivations corrupted
  each other's cwd, silently degrading full-mode fingerprints to
  parse-mode (observed: registry-invariant + dedup checks failing under
  jobs=8, passing serial). Validated: parallel==serial across repeated
  runs; 4 real concurrent adjudications 59s wall, correct verdicts.
- scripts/compare_forge_solc_interpreter.sh: --jobs ${JOBS:-10}
  --timeout ${TIMEOUT:-600} defaults (cases are subprocess-isolated; OZ
  lanes run ~290s and trip the old 300s default under contention).
  Explicit args still win (argparse last-occurrence).
2026-07-22 18:57:59 -04:00
arena-lean-staging-agent[bot]
9a60f5d1c7
fix: call through internal fnptr returned then immediately called (pick(true)(x)) (#13)
An internal function that returns an internal function pointer which is
immediately called — `pick(true)(x)` — failed closed at three points on an
in-scope, solc-accepted program:

1. Importer: solc annotates the callee expression of a call with
   `argumentTypes` for every callee node shape. The `FunctionCall` callee case
   (a returned pointer directly invoked) left
   `FunctionCall.argumentTypes.typeIdentifier` / `.typeString` UNCLASSIFIED, so
   the frontend fail-closed. Classify them as analysis metadata, consistent
   with the already-classified `Identifier`/`MemberAccess`/`IndexAccess`/
   `TupleExpression`/… callee shapes.

2. `abiTyWithInternalFunctionsEnv?`: the non-identifier-callee call arm typed
   the callee via `abiTyWithEnv?`, which cannot resolve an internal call, so a
   call-valued callee (`pick(true)`) had no inferred type. Use the
   internal-functions variant so the returned pointer's return type resolves.

3. Executable lowering: the `Expr.call callee args` arm only handled a callee
   the pure read lowering could evaluate. Factor `ptrBoundaryCallExprParts?`
   into a core-taking `ptrBoundaryCallCoreParts?` and add a fallback that
   hoists a call-valued callee into a temp fn-ptr (via the existing
   single-return machinery) and dispatches through it — the same boundary as
   `arr[i](x)`, `(c ? a : b)(x)`, and `s.fp(x)`.

Ground truth solc 0.8.35 + EVM for `run(3)`: `dbl(3) + trp(3) = 6 + 9 = 15`.

Co-authored-by: Lean Semantics Review Agent <agent@solidcore.local>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-20 12:59:04 +00:00
arena-lean-staging-agent[bot]
d0668dcecf
fix: call through ternary-selected internal fn pointer ((c ? a : b)(x)) (#9)
An in-scope, solc-accepted program that calls directly through a ternary
selecting between two internal functions — `(tick() ? a1 : a2)(x)` — failed
closed twice:

  * the solc-AST importer left `TupleExpression.argumentTypes.typeIdentifier`
    / `.typeString` UNCLASSIFIED. solc annotates the parenthesized callee node
    with `argumentTypes` (the call's argument types) exactly as for the
    Identifier/IndexAccess/MemberAccess/... callee shapes, but TupleExpression
    was omitted, so import rejected before producing any AST; and

  * the executable lowering could not lower a call whose callee is a ternary
    with a side-effecting condition and function-identifier branches: routing it
    as a call THROUGH the ternary as a function pointer cannot recover the
    pointer type once the identifiers become dispatch-ID literals.

Fix: classify the two TupleExpression.argumentTypes fields as analysis fields
(purely additive), and DISTRIBUTE a call over a ternary callee
(`(c ? a : b)(args)` -> `c ? a(args) : b(args)`) in `FunctionDecl.toCore?`
before the fn-value dispatch-ID rewrite, so the branch functions stay
name-resolved direct calls handled by the existing internal-call ternary
lowering. solc evaluates the callee (hence `c`) first, then args, then the
selected function; distribution preserves that order and single-evaluation.

Real solc 0.8.35 + EVM ground truth for run(3): r1=a1(3)=4, r2=a2(3)=6, t=2,
returns 4*10000 + 6*100 + 2 = 40602 (0x9e9a), final storage t=2 — reproduced
end-to-end (importer -> checker -> interpreter) and pinned by the
FnPtrTernaryCall witness.

Co-authored-by: Lean Semantics Review Agent <agent@solidcore.local>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-20 09:28:24 +00:00
arena-lean-staging-agent[bot]
5463e2b073
fix: call through internal-fn-pointer array element (arr[i](x)) (#8)
An in-scope, solc-accepted program that calls through an element of a fixed
array of internal function pointers failed closed on this engine — first at
import, then (once import was fixed) in the executable lowering.

Two responsible gaps closed:

1. Importer (scripts/solc_ast_to_lean_source.py): the callee-context
   `argumentTypes.typeIdentifier` / `.typeString` scalar fields were classified
   as analysis metadata for every callee node shape EXCEPT `IndexAccess`. solc
   emits these on an `IndexAccess` when it is the callee of a call (an element of
   a function-pointer array), so the coverage self-check fail-closed on an
   in-scope program. Added the two `IndexAccess` entries to ANALYSIS_SCALAR_FIELDS.

2. Executable lowering (SolidCore/Solidity/Interface.lean): every internal call
   was keyed on a callee NAME, so a call through a non-identifier
   function-pointer expression (an array element) was declined even though the
   interpreter already supports `Stmt.internalCallPtr` with an arbitrary fn
   expression. Generalized `ptrBoundaryCallParts?` to
   `ptrBoundaryCallExprParts?` (callee expression + return prefix), taught
   `Expr.abiTyWithInternalFunctionsEnv?` to type a call through a non-identifier
   internal-fn-pointer callee, and added the non-identifier callee case to
   `internalExprSingleReturnUseCore?` plus a narrow `return arr[i](x)` arm.
   Non-pointer callees still decline to `none` (over-reject preserved).

Ground truth (solc 0.8.35 + EVM) for the reported program run(3) = 604 (0x25c):
arr[1](3)=a2(3)=6, arr[0](3)=a1(3)=4, 6*100+4=604.

Regression: SolidCore/Witness/FnPtrArrayIndexCall.lean (#guard run(3)=604,
run(5)=1006, run(0)=1). Full `lake build` (all proofs) green; smoke replay
(29 cases) paired_cases_passed=yes.

Co-authored-by: Lean Semantics Review Agent <agent@solidcore.local>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-20 08:25:48 +00:00
Dan Robinson
237a4b8596 gap/abi-decode-address: force decoded address to payable + require tuple type arg
Two related fixes in abi.decode handling, matched to pinned solc 0.8.35.

FIX A (over-reject, replay-reachable): solc forces every top-level decoded
`address` component of abi.decode's result to `address payable`
(TypeChecker.cpp:150-152, typeCheckABIDecodeAndRetrieveReturnType). The model
returned plain `address`, so `address payable p = abi.decode(data,(address))`
and `.transfer`/`.send` on a decoded address over-rejected. Coerce each
top-level `Ty.address false` result component to `Ty.address true` in the
typechecker (TypeCheck.checkExpr abi.decode call site) and in the lowering
type oracle (Interface.Expr.abiTy?). The coercion is top-level only — addresses
nested inside a decoded array/struct are NOT rewritten (solc rejects
`abi.decode(data,(address[]))[0].transfer(1)` and a decoded struct address
member; both re-probed against the pinned binary).

FIX B (over-accept): the second argument to abi.decode must be a TUPLE of types
(TypeChecker.cpp:127-136, error 6444); bare `abi.decode(data, uint)` is rejected
while `(uint)` is accepted. The importer collapsed single-element tuples, making
`(uint)` and bare `uint` both `Expr.typeName` and indistinguishable. Preserve
the tuple wrapper for abi.decode's type argument in the importer, then reject
the bare `Expr.typeName` branch in checkAbiDecodeTypesExpr and
Expr.abiDecodeSourceTypes?. Only the parenthesized shape now accepts.

Gate: full `lake build` (1107 jobs) green. New sanctioned replay lane
abi-decode-address-payable (forge=ok, lean=ok, compare=pass). Existing
single-type decode lanes (abi-malformed, abi-struct-tuples,
uniswap-transfer-helper) still pass after the importer change. Four acceptance
witnesses added (bare reject; (uint), (uint,bool), address-payable accept).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-09 22:58:32 -07:00
Dan Robinson
494c50468a gap/qualmember: lower qualified type-name member access (#102 cluster)
The type-name member arm over-rejected several forms of member access read
THROUGH a contract/interface/library qualifier rather than through a value.
solc accepts all of them (verified against the pinned 0.8.35 binary); the model
failed to typecheck/lower them and rejected the whole contract. Fix each:

1. Qualified CONSTANT (`Base.K`, `L.LK`): checkExpr resolves the constant/state
   member type; a `.`-joined qualified `ConstantEnv` (built from every
   contract/library in scope) inlines the value in `inlineConstants`.
2. Qualified ENUM VALUE (`Base.E.C`): the importer now collapses a nested
   type-expression MemberAccess (`Base.E`, `t_type$…`) into a single
   `Ty.user {Base, E}` path, so it matches the existing `member (typeName path)
   case` enum-value resolution.
3. Qualified STATE VARIABLE (`Base.v`): checkExpr resolves the inherited storage
   var (lvalue + state read); `toCore?`/`toCoreLValue?` lower it to the same
   storage/immutable slot as the bare identifier.
4. Qualified SELECTORs (`I.IE.selector`, `L.g.selector`, `L.LE.selector`):
   checkExpr falls back to the type name's error/external-function table when
   external-function-value resolution declines; lowering already resolved these.
5. Library-qualified error in a revert (`revert L.LE(9)`): checkExpr resolves the
   error against the library's table, and library errors are added to the
   CoreContract runtime error table so the selector + args encode soundly
   (reverses the earlier conservative decline; the selector is scope-independent).

Adds the sanctioned replay lane `qualified-member` (own-call fixture + forge
ground truth; all 8 real-EVM values confirmed) and manifest entry. Full
`lake build` (1107 jobs) green.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-09 22:57:51 -07:00
Dan Robinson
7d60021a13 keccak from EVMYulLean pin b08573c; alphabet imports via EvmInteraction.* modules
- evmyul pin 3c5c44a6 -> b08573c: the package now provides the pure total
  Keccak-256 sponge as the Lean body of ffi.keccak256 (@[extern]-accelerated).
  SolidCore/Solidity/Keccak.lean becomes pure re-exports (names unchanged);
  the repo-owned implementation is deleted — source semantics and EVM/Yul
  target semantics now share ONE keccak definition, so lowering seams need no
  keccak-equality hypothesis. keccakParity retained as native-vs-Lean-body
  witness (11 cases OK).
- Interaction.lean bridge imports move to EvmInteraction.Simulation.* (the
  evm-interaction package's new module paths; namespaces unchanged).
- check_shared_interaction_hashes.py repurposed: byte-identity between two
  live copies -> single-source assertion (evm-compiler stubs re-export the
  package; real sources only in evm-interaction).

Verified: lake build green (1107 jobs); keccakParity OK; AST audit
rendered_sources=182 render_failures=0; FULL REPLAY GREEN:
forge_interpreter_compare=pass status=0 cases=189 paired_cases_passed=yes.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Dy3P966aQiG3jen2yKuNeu
2026-07-09 14:42:24 -07:00
Dan Robinson
1089b6c840 SB-A (#80): import non-UTF-8 plain string literals via hexValue fallback
A plain "..." string literal whose bytes are not valid UTF-8 (e.g.
"\xff\x00\x41") makes solc omit the AST `value` field and keep only
`hexValue`. The importer's `kind == "string"` branch fail()ed on the
missing value, excluding solc-ACCEPTED programs from the corpus.

Fall back to `hexValue` and lower as Literal.hexString (identical to the
sibling hexString branch). This matches solc's boundary exactly: such a
literal has type literal_string hex"..." — converts to bytes (ACCEPT in
both bytes(...) and bytes memory = contexts) but not to string (REJECT).
Literal.hexString.abiTy? = Ty.bytes reproduces this in Lean; no Lean
change needed. New path triggers only when `value` is absent, so no
existing fixture's import changes.

New lane nonutf8-string-literal pins length/bytes/keccak in both bytes
contexts plus invalid/StringNonUtf8.sol for the string-context reject.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
(cherry picked from commit 27450d881a63bc855e6e382c86c849d76caa5726)
2026-07-09 14:07:34 -07:00
Dan Robinson
9e788bfb7c #59/UNI1: importer emits real UTF-8 for unicode"..." non-BMP code points
`scripts/solc_ast_to_lean_source.py` built every Lean string literal with
`json.dumps(value)` (default `ensure_ascii=True`), which encodes a non-BMP
code point (e.g. U+1F600 GRINNING FACE) as a UTF-16 SURROGATE PAIR in the
generated `.lean` source. Lean 4 does not recombine surrogate escapes, so
`bytes(unicode"😀")` decoded to [0,0] (2 null bytes) instead of solc's
[240,159,152,128] (4 UTF-8 bytes), and `bytes2(unicode"😀")` spuriously
over-accepted (2 <= 2) while solc rejects (4 > 2).

Fix (importer only; no Lean semantics changed):
- `lean_string`: `json.dumps(value, ensure_ascii=False)` emits real Unicode
  characters (Lean reads source as UTF-8) while still escaping
  quotes/backslashes/control chars, so ASCII/BMP/2-3-byte literals import
  unchanged.
- `main`: force `sys.stdout.reconfigure(encoding="utf-8")` so emitted
  characters reach the harness regardless of process locale.

Verified: emoji round-trips to 4 bytes on both solc and the imported Lean
interpreter; 你 stays 3 bytes; ASCII unchanged. The now-correct 4-byte decode
makes the existing string->bytesN gate (`fixedBytesWordFromBytes?`,
`bytes.length <= size`) reject `bytes2(unicode"😀")` (checked via
`TypeCheck.checkExpr`), closing the over-accept.

New paired lane `unicode-nonbmp`: pure `unicode"😀"` + mixed `unicode"a你😀b"`
(byte length, individual UTF-8 bytes, keccak256(bytes(...))), plus a
`solc_rejects` fixture for `bytes2(unicode"😀")`. forge=ok lean=ok
forge_interpreter_compare=pass.

Full `lake build` green (1106 jobs). Importer output is byte-identical to
baseline for every ASCII-only fixture, so zero regressions from this shared
importer change.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-09 05:31:01 -07:00
Dan Robinson
fdd793c62a DIV-CREATE-1/2 fixed: contract-creation option/argument evaluation ORDER
solc 0.8.35 evaluates `new C{value, salt}(args)` as the {…} options in source
order FIRST, then the constructor argument LAST. solidity-lean diverged twice:

- DIV-CREATE-1 (try-create): Stmt.tryContractCreate sequenced args→value→salt
  (args-first), disagreeing with solc and with the plain-create handler.
- DIV-CREATE-2 (plain-create): the lowering collapsed {value,salt} and
  {salt,value} to an unordered pair and the handler evaluated right-to-left
  (always salt→value→args), so {value,salt} came out value/salt swapped.

Fix (mirror of EO1): Expr.contractCreate and Stmt.tryContractCreate carry a
valueBeforeSalt : Bool threaded from lowering (like gasFirst for external
calls). Both handlers now evaluate the options in source order, then the args
last — the fixed top-level order imposed sequentially, each component's inner
children keeping the ambient child-eval order. The two handlers now agree with
each other and solc. FuelMonotonicity's tryContractCreate case updated to the
new options-first control flow (split on the option-eval, mirroring the EO1
tryExternalCall case).

New Forge-paired lane tests/forge-harness/create-order pins the observable:
value/salt/arg order-trace 123 for {value,salt} and 213 for {salt,value},
identically for plain `new` and `try new`. lake build green (1103 jobs incl
FuelMonotonicity + Witness); smoke replay green, no regressions; lane
forge=ok lean=ok compare=pass.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-09 01:19:24 -07:00
Dan Robinson
3c53d0fb9c rename: Solidus → solidity-lean; package solid-core-spine → solidity-lean
Rename this project's name/nickname "Solidus" to "solidity-lean" and the
package "solid-core-spine" to "solidity-lean" across docs, Lean comments,
the contest tooling, and fixture comments.

- lakefile.lean / lake-manifest.json: package «solid-core-spine» → «solidity-lean».
- docs/solidus-solc-deep-comparison.md → docs/solidity-lean-solc-deep-comparison.md
  (git mv), with every reference updated (docs, Lean, manifest, fixture comments).
- contest/: renamed the functional wire token solidus-reject → solidity-lean-reject
  (Lean emitter + Python parser) and all internal identifiers (run_solidus_observable,
  SolidusResult, is_solidus_reject, evidence keys, temp dirs) consistently.
- Preserved: EvmCompiler.Solidus and all references clearly naming the sibling
  ../evm-compiler project (ARCHITECTURE.md, ROADMAP.md, docs/compile-to-yul-readiness.md),
  the SolidCore Lean namespace, the keccak256("solid-core-spine …") fixture strings,
  and the external solid-core-spine-audit path.

Gates: lake build (1102 jobs) OK; scripts/smoke_replay.sh SMOKE_JOBS=6 status=0
paired_cases_passed=yes; contest/run_samples.py ALL SAMPLES CLASSIFIED CORRECTLY;
manifest case count unchanged.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-08 23:33:51 -07:00
Dan Robinson
5cd19032ce gap/round3-pk1-cl1: PK1 nested-static-array encodePacked + CL1 bare base-ctor reject
PK1 (over-reject, live differential edge) — solc accepts abi.encodePacked of a
nested STATIC array whose ultimate element is a static value type; reject only an
array whose base is a dynamically-sized array (typeSupportedByOldABIEncoder,
TypeChecker.cpp:55-68 / :2166-2174).
  - TypeCheck.lean: Ty.isAbiEncodePackedArrayElementShape gains a Ty.array case
    (accept iff inner dimension is static, recurse on element).
  - Interpreter.lean: abiEncodePackedArrayElement? recurses into a fixedArray
    element, padding each innermost value to a 32-byte word in-place.
  Probe-confirmed: uint[2][3], uint[2][], uint[2][2][2] ACCEPT; uint[][3],
  uint[2][][2], bytes[], string[] REJECT (9578).

CL1 (over-accept, importer-masked) — solc errors 1563 on a bare modifier-style
base-constructor call (constructor() Base {}, no arg list); Base() is fine
(ContractLevelChecker.cpp:366-382).
  - Ast.lean: ModifierInvocation gains hasArgList : Bool := true.
  - solc_ast_to_lean_source.py: emit hasArgList from solc arguments==null vs [].
  - TypeCheck.lean: ModifierInvocation.check rejects a base-constructor modifier
    with hasArgList=false.

Lanes: new manifest case packed-nested-static-array — Forge accept lane
(128-byte padded layout vs solc's abi.encodePacked) + solc-reject fixtures
(PackedDynamicInnerArray uint8[][3], BareModifierBaseConstructor) + solc_import
+ Lean typecheck/value witnesses. Harness: solc_rejects=ok forge=ok lean=ok
forge_interpreter_compare=pass. Smoke replay green (28/28, no regression).

docs: solc-implementation-divergences-3.md PK1/CL1 marked FIXED; DECISIONS.md
dated entries.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-08 14:58:08 -07:00
Dan Robinson
735cae1486 G1: dispatch user-defined operators to their bound function, not the builtin
Since Solidity 0.8.19 `using {f as +} for T` binds an operator to a free
function; solc resolves `a + b` to a call of `f(a,b)` that runs with the
operator function's own checked/unchecked context. The importer dropped solc's
resolved operator reference and lowered the node to a builtin Expr.binary/unary,
so the interpreter applied the BUILTIN op on the raw underlying words — wrong
value AND wrongly accepted whenever the operator body differs from the builtin
(e.g. fixed-point `*` = (a*b)/1e18: applyInterest(500e18,0.1e18) was ~5e37, solc
is 550e18).

Fix (importer only): when a BinaryOperation/UnaryOperation carries solc's
non-null `function` FunctionDefinition id, render it as an ordinary call
`Expr.call (Expr.ident opFn) [a, b]` (unary `[a]`) instead of Expr.binary/unary.
The existing internal-call boundary (Stmt.internalCall) then resolves the free
function and resets checked:=true for the callee body, giving correct value,
per-body checked/unchecked semantics, bool comparison results, unary/binary `-`
disambiguation, and recursion. No trusted-Lean change needed.

- scripts/solc_ast_to_lean_source.py: collect_function_names_by_id (id->name),
  user_defined_operator_name, and the two expr_from_node arms.
- New Forge-paired lane tests/forge-harness/udvt-operator-dispatch pinning
  550e18, minus disambiguation, bool comparisons, and word-width checked/
  unchecked-per-operator-body context.

Gates: lake build SolidCore green; smoke_replay 28/28 lean=ok compare=pass; new
lane + frontend-frontier forge=ok lean=ok. DECISIONS.md 2026-07-08 entry added.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-08 08:34:56 -07:00
Dan Robinson
06ac6307aa fix/tuple-hole: importer coverage-audit gap for tuple-with-hole assignment
The interpreter core, surface AST, typechecker, and executable elaboration
already model tuple holes end-to-end (TupleItem.hole -> none slot ->
LValues.writeTuple). The only break was the solc-AST importer's coverage
AUDIT, not its renderer: a null entry in a TupleExpression.components list was
classified as an unclassified scalar field, hard-failing with
"unclassified Solidity AST scalar fields present: TupleExpression.components".

Fix: register ('TupleExpression', 'components') in SOURCE_SCALAR_FIELDS, exactly
mirroring the existing ('VariableDeclarationStatement', 'declarations') workaround
for declaration holes. One line; no Lean source changed.

Pinned by a new tuple-holes corpus lane: leading/middle/trailing holes in
assignment and declaration LHS with a side-effecting RHS (pokes++, proving the
held-out slot is still evaluated), the canonical value-carrying idiom
(bool ok, ) = t.call{value:1}("") observing the send debit, plus 3 solc_rejects
for the illegal forms (empty tuple target (,), hole+arity mismatches).

solc 0.8.35 boundary probed. Corpus: 102 cases, 445 lean_evals (+5),
314 solc_rejects (+3). Gates green: lake build SolidCore, smoke_replay (28),
--only tuple-holes, --only tuple-destructure --only low-level-call-options,
frontend audit.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-07 06:57:22 -07:00
Dan Robinson
ad2a78ae7e Harness: raise per-#eval maxHeartbeats to 8000000 in generated interpreter files
The 200k default caps each #eval at ~50s of interpretation; construct-heavy OZ
lanes sat just under it pre-refactor and cross it after the function-boundary
refactor's ~1.7x elaboration overhead. The per-case wall-clock timeout remains
the perf gate.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-07 02:04:45 -07:00
Dan Robinson
d6e6ef8e22 A1: widen NumberRat Nat->Int, fixing the rational-constant over-reject
The audit (5c26c24) corrected the gap registry's suspicion: A1 was recorded as
suspected unsoundness, but the NumberRat folder already folds in unbounded ℚ and
gates integer results on exact division (0 WRONG-VALUE divergences). The real
gap was OVER-REJECTION (completeness): NumberRat over Nat rejected any negative
fold (0-5, 3-10, 7/2*2-100 = -93) that solc accepts.

Engine (Interface.lean):
- NumberRat.num : Nat -> Int (den : Nat strictly positive; mk? canonicalizes
  sign onto the numerator).
- NumberRat.sub is now total; BinaryOp.applyNumberRat? sub => some (lhs.sub rhs).
- div? routes the signed denominator through mk?; pow over Int handles negatives.
- New exactInt?; exactNat? = exactInt? filtered to >= 0 (bit/shift/mod and
  unsigned targets still reject negatives).
- numberLiteralRat?/untypedNumberLiteralRat? gain a real unary-neg case; new
  numberLiteralInt?.
- toCoreNumericLiteralAs? collapsed to one signed range test per target;
  negatedNumberLiteralNat? and the split fit helpers removed.
- TypeCheck.fixedPointLiteralRaw? adjusted for the signed numerator.
Everything stays total (no partial).

Importer (solc_ast_to_lean_source.py): type_from_expression_node's array-length
in type-expression position gains the already-folded typeString/typeIdentifier
fallback the VariableDeclaration path already had.

Regression guard: new rational-constants corpus lane + SolidCore.Witness.
RationalConstants pin the three folds (-5/-7/-93), their acceptance into int256,
and that fractional-into-int and negative-into-unsigned still reject (no
over-correction into unsoundness).

Docs: docs/DECISIONS.md entry; ROADMAP gap registry marks the over-reject fixed
and records the audit found no unsoundness.

lake build SolidCore green; rational-constants lane green
(solc_rejects=ok forge=ok lean=ok); smoke_replay green (28 cases, no regression).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-06 13:30:48 -07:00
Dan Robinson
574e556cb4 Phase 5 stage 0: repair SolidCore build red at HEAD; harden smoke; add plan
sub-step-1a changed the expression evaluator to return SolI but left two
constant-eval witnesses in Witness/Interface.lean matching Except.ok against it,
so `lake build SolidCore` was red at HEAD. The replay harness never builds
SolidCore.Witness.*, so the green replay hid the library break (a green replay is
not a green build). Wrap both scrutinees in SolI.foldExpr as the ...ByContext
adapters do (arms byte-identical; both still #eval to some true).

Harden scripts/smoke_replay.sh to `lake build SolidCore` first so this can't
recur. Add docs/phase5-propagation-plan.md (Fable-designed: control-flow model A
refined, 8 buildable stages, build-validated PoC) as the plan for the remaining
Stmt.eval -> Contract.call tree propagation.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-06 11:51:20 -07:00
Dan Robinson
a6d3f7dfe3 harness: opt-in --jobs parallelism (~2.8x faster dev loop)
The harness ran the 98 cases sequentially on 1 of 14 cores; per case is ~4s of
fixed SolidCore olean loading plus a variable pure-Lean #eval (heavy contracts
run a minute+). Add an opt-in --jobs N flag (default 1 = byte-identical to the
original sequential loop, so the official full-replay gate command is unchanged):
cases run in a ThreadPoolExecutor with per-case stdout captured via a
thread-routing stdout proxy and replayed in manifest order.

(The first cut used contextlib.redirect_stdout, which swaps the process-global
sys.stdout and corrupts capture across threads — only 1 of 28 case lines
survived; a thread-local router fixes it. Verified --jobs 5 emits all cases in
manifest order with the correct pass summary; --jobs 1 output is byte-identical.)

smoke_replay.sh now passes --jobs 10 (override SMOKE_JOBS): sequential smoke 770s
-> parallel 272s (the floor is the single longest heavy case). Dropped the
redundant solmate-erc20 sentinel.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-06 11:05:51 -07:00
Dan Robinson
3be51fb695 Phase 5 (sub-step 1a): expression evaluator emits Query.external; add smoke replay
Convert the expression evaluator to the shared interaction monad. The
...OrderFuel mutual block, the ...Order wrappers, and the evalReturn*Order family
now return SolI (Value × Runtime) instead of Except RevertData (Value × Runtime)
(Except.ok -> pure, Except.error e -> throw (SolidityFailure.revert e), via a
MonadLift (Except RevertData) SolI). The 2 live low-level-call sites now
emitLowLevelCall (a Query.external node) instead of resolveLowLevelCall. The
...ByContext boundary functions stay Except-returning and fold the SolI tree via
SolI.foldExpr fuel context (runFromContext against the replay-from-Context oracle),
fuel = orderFuel expr + 1.

Hardening from a Fable review of this increment (both dormant, fixed before
commit): callKindToLowLevel .callcode now maps to .callcode (not .call);
answerCall now matches the exact sent gas first (was none-first, which could
shadow a gas?=some row). Fuel bound verified safe (query count <= syntactic
lowLevelCall nodes <= orderFuel; .outOfFuel unreachable). Residue for sub-step-1b:
a third Stmt.eval external site and the 2 create sites still read the oracle.

Also add scripts/smoke_replay.sh: a curated ~29-case Lean-only (--skip-forge)
subset for the dev loop; the full replay remains the commit gate.

Full corpus replay green: forge_interpreter_compare=pass, cases=98,
paired_cases_passed=yes. Details in docs/DECISIONS.md.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-06 10:43:10 -07:00
Dan Robinson
b17f0d21f3 Phase 3b: rename Spine/L00_SourceSolidity -> SolidCore.Solidity; split out Ast.lean
Remove the vestigial compiler-spine naming and start the target module tree.

- Three-sided rename SolidCore.Spine.L00_SourceSolidity -> SolidCore.Solidity:
  6 Lean files, the manifest (1775 occurrences: imports, every eval expr,
  every solc_import.namespace), and the 3 harness scripts' hardcoded
  namespaces/imports. No collision with the existing SolidCore.Solidity.Source.*
  runtime layer.
- Move the base modules to SolidCore/Solidity/{Interface,TypeCheck,Checked}.lean;
  delete SolidCore/Spine/ and its stale READMEs; SolidCore.lean imports the
  Solidity modules directly.
- Split the ~430-line surface AST (Literal/Expr/Stmt/FunctionDecl/SourceUnit/...)
  out of Interface.lean into SolidCore/Solidity/Ast.lean at the clean
  pre-`namespace Executable` boundary (zero forward refs). Interface.lean keeps
  elaboration + the (Phase-4-doomed) observation layer and imports Ast.

Verified end-to-end on one case (generator+manifest+eval) before the full run.
Full corpus replay green: forge_interpreter_compare=pass, cases=98,
paired_cases_passed=yes; eval count unchanged (420). Decisions in docs/DECISIONS.md
(incl. deferring evaluator consolidation (3d) until after Phase 4, since most
old-evaluator call sites live in observe* walkers that Phase 4 deletes).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-06 05:23:10 -07:00
Dan Robinson
5b67537cc6 Phase 2: depend on the extracted shared interaction package
Add the sibling `evm-interaction` package (a verbatim, byte-identical extraction
of evm-compiler's EvmCompiler/Simulation/{Interaction,OpenWorld,Outcome}.lean) as
a Lake path dependency and program this repo against the real composition
alphabet from day one.

- lakefile: require «evm-interaction» from "../evm-interaction"; manifest updated
  via `lake update` (path dep added; all other revs unchanged, Mathlib from cache).
- SolidCore/Solidity/Interaction.lean: bridge module importing the package and
  aliasing Interaction/Query/Answer/OpenWorld/ForwardRel under
  SolidCore.Solidity.Shared. Reachable from the SolidCore root so `lake build`
  checks linkage; off the corpus build path so the corpus is unperturbed.
- scripts/check_shared_interaction_hashes.py: sha256-compares the sibling's three
  Simulation files against ../evm-compiler's live sources read-only
  (shared_interaction_hashes=pass). Guarantees drift-freedom; `skip`s (does not
  fail) when the reference checkout is absent.

The closure separates cleanly — the three files import only the pinned evmyul
package + Mathlib, no other EvmCompiler.* module — so no in-repo vendoring was
needed. Full corpus replay green: forge_interpreter_compare=pass, cases=98,
paired_cases_passed=yes. Decisions in docs/DECISIONS.md.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-06 03:39:47 -07:00
Dan Robinson
e53af6756f Checkpoint: full June source-semantics work (98-case corpus, harness, typechecker/interpreter growth)
Six weeks of uncommitted work: solc-AST importer + Forge differential
harness (98 cases, 420 eval assertions, ~309 solc-reject lanes),
typechecker acceptedness slices, observation layer, interpreter and
elaboration growth through the 2026-06-30 progress log entries.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-06 00:35:19 -07:00