Skip to content

feat(cil): migrate execution and proof bindings to decoded CIL - #602

Merged
benaadams merged 1792 commits into
mainfrom
feat/canonical-cil
Nov 26, 2026
Merged

benaadams merged 1792 commits into
mainfrom
feat/canonical-cil

Conversation

@benaadams

@benaadams benaadams commented Nov 14, 2026 •

Copy link
Copy Markdown
Member

Closes #582, #568, #596, #597, #598, #627.

Follow-up issues

Each acceptance criterion this PR leaves unmet is tracked in its own issue.

Implemented

  • Pins, slices and owners are identified by typed AssemblyName (name, version, culture, public key token): the reader derives each slice's name from its Assembly row, the pinned index is keyed by it, and AssemblyPin, BodyEvidence.identities, AttributionValid and the strict binding claims hold it. A neutral and an empty culture now name different assemblies (neutral_culture_is_another_assembly). Consumer-visible: AssemblyPin.identity and Extracted.assembly{k}Identity are AssemblyName, the new assembly{k}Scope states the scope text, AssemblyMetadata holds publicKeyToken : Option Nat, BodyDecodes states body.identities.head? = some pin.identity, and pinned_identities_spelled is now pinned_identities_listed. Shared tactic tests are unchanged in heartbeats; whole extractions are 4 percent lower (Compare types by typed identity in every extraction check #610).

  • A multi-method extraction binds each literal-message exception construction to its pinned CoreLib constructor: the CoreLib rows are appended once after the local methods and checked with ManagedPackage.rowValid, and cil_evaluated writes the bound caller as a literal proved equal to its binding. ItemPool.Rent's exhausted throw runs InvalidOperationException(string); rent_exhausted_throws gains premises for the message literal's binding, its formObject and heap budget for the exception, with its conclusion unchanged, and poolClasses lists the CoreLib exception classes. Checking Rent's extraction takes about 74 to 83 s against about 12 s folded (Measure and reduce the checking cost of ItemPool.Rent's bound extraction #628). Other extractions are byte-identical (Use canonical decoded CIL as the sole executable instruction representation #568, Migrate checked execution and consumer proofs from CIL.Op to canonical CIL #598).

  • An enum type carries its typed identity and its integer storage (TypeExpr.enum identity storage), so an enum over another enum, a non-integer or a struct cannot be written. Admission compares the storage with the definition's element code, and the extractor writes the storage of the validated value__ field. declaredNarrow_enum and Method.elementShape_enum take the storage; declaredNarrow_enum_of_none and the enum-chain walk in resolution facts are removed (Compare types by typed identity in every extraction check #610).

  • A loop summary requires an invariant and a termination measure: SegmentContract.Holds.loop and DecodedSegmentSummary.loop derive a contract that reaches the loop exit from per-iteration contracts that exit or decrease the measure. SegmentContract.Holds.preserves states that every continuing or returning exit keeps earlier allocations live and returns the same bytes for reads apart from the footprint. A countdown loop is proved with both; a self-loop has no exit summary (Derive and reuse checked semantic summaries over canonical CIL sequences #597).

  • cil_runtime_models reports a call whose runtime model the kernel resolves but the elaborator cannot reduce, naming the method, pc and stuck term. Each extraction states its raw layout rows as separate definitions, so 512 chained generic rows compile. The deep audit adds imported-layouts and member-links facts (certificate schema 9) recomputes the own key token, and reports unpinned packaged CoreLib rows as not covered. Add, Choose, GenericIdentity, Struct, Countdown and CountCalls each refute their own named contract.

  • A struct's field shape facts name its two layout entries once and read its field lists through block suffixes, so a fact's cost does not grow with the field's index. A spread-row operand now costs 26.1k-29.6k heartbeats, up from 21.6k-24.7k, at every field index.

  • Scalar generics bind MethodDefs, exports and contracts. Four MemberRefs reject swapped owners. EnumDigit returns 12 and binds each Rows.Choice TypeDef and its defining assembly's raw culture.

  • Scalar structs bind TypeDef, ClassLayout, Field and FieldLayout. Moving a field preserves IL, refutes both readers (0 for 128) and fails comparison of raw, specialized and decoded methods.

  • Typed catch and finally clauses execute; Lean decodes and checks exception sections and filter and fault clauses are refused. An SDK-built 489-byte try and 6-byte catch bind the original class, cleanup kind and endfinally. OutcomeTrace carries the invariants through handlers (Use canonical decoded CIL as the sole executable instruction representation #568, Kernel-check canonical CIL decoding against exact method bytes and metadata #596, Migrate checked execution and consumer proofs from CIL.Op to canonical CIL #598).

  • Class slots bind inherited and cross-assembly overrides, MethodImpl rows, nested types and byrefs. Lean checks each target in its defining DLL. Foreign and local overrides return 20 and 12 (mutants 22 and 11). Strings retain reference type. Primitive signatures bind the core AssemblyRef without an Object TypeRef. Class tests return null or throw InvalidCastException on failure. The CLR and Lean distinguish both allocated Rows.Widget types.

  • GenericParamConstraint binds nested types through pinned TypeDefs and forwarders. Pair<int,long> binds !1 and rejects !0/!2. At U=int both closed interfaces hold. Entry(x) preserves memory and returns x + 2 for every Int32.

  • Forwarded calls return x + 1 for every Int32 and reject 13 mutations. Carried and deep PE binding check name, version, raw culture and publisher across forwarders. Empty culture and literal neutral differ.

  • UInt32 division and checked narrowing preserve caller memory. Compiled mutants give 12 for 6 / 2 and 0 for 256. The value constructor preserves all 64 bits from empty memory. Its mutant wraps UInt64.MaxValue to zero.

  • Portable 256/512-bit equality preserves memory. A repeated operand fails at the top bit. At count 256 both truncated AVX2 shifts return 1 instead of 0. AVX2 AND-NOT(1,2) returns 2. Reversed operands return 1.

  • Removing StackOperation and its array preserved 108 outputs and 12,667 admissions. Outlines read Cecil instructions.

  • x64 and ARM64 AES satisfy one round contract for every state and key. Repeating the low key half gives a verified one-bit counterexample on both profiles.

  • Closed typeof retains both ldtoken/getter pairs and comparison or branch. Four changed System.Type signatures fail. Five-step SegmentRun accepts any frame, stack and memory. Three compiled methods cover all Int32 inputs and match 15 CLR results. Other costs 2,299,693 heartbeats shared, 2,411,159 directly and 1,158,900 folded.

  • Pinned CoreLib String and Object TypeDefs bind reference values. The length getter returns its readable field in unchanged memory. Monitor.Enter checks the flag, propagates callee faults and writes one byte after a successful call. The x64 GetHeaderPtr body subtracts four bytes within the same allocation and preserves memory. Thin-lock ownership remains open.

  • On .NET 11.0.0 Windows x64 NativeAOT IL-only CoreLib, the CLI verifies Math.Min(Int32, Int32) for all signed inputs and caller memory. Math.Max(-1, 1) returns 1 and refutes the contract. Both use default binding. The Min helper and contract use propext and Quot.sound.

  • CI runs 81 suites in 14 groups.

  • Both readers require an earlier nonzero enclosing TypeDef. Strict binding checks generic bases and field ranges. Structs and enums bind core scope, token and neutral culture. Pinned .NET 11 CoreLib fixes primitive and stack widths. Its fieldless Object terminates layout. The kernel checks long assembly identities.

  • Templates share callee numbering and report the first differing pc. Compiled ldftn binds its index. A two-assembly struct call binds owner, token and arguments (2,713,469 kernel heartbeats both ways). Seven call and field extractions and outlines match. Renamed or reindexed stores fail at pc 1.

  • Lean checks tiny and fat headers, instructions, operands, branches, stack depth and initialized locals. Public execution refuses exception sections. The 56-byte CoreLib resource getter contains 25 IL bytes.

  • Check method identities, signatures, locals, generic constraints, type operands, fields and call targets against carried metadata. Object parameters bind the core scope and name. Nongeneric forwarded calls bind open signatures in the caller and closed signatures in the defining module. Four scope mutations fail. Shared indexes avoid repeated scans. Omitted heap entries distinguish zero and maximum-width offsets.

  • Method.argumentAccess reads arguments from the declared signature and homes. Its method{n}_argumentAccess{i} facts and reduceArgumentAccess simproc cost about 8,400 kernel heartbeats per argument at 8, 32 and 128 arguments (10,800 with homes). The lookups suite rejects quadratic growth.

  • Feature certificates store known words as sorted local-index and word pairs. Kernel heartbeats per instruction at 16, 64 and 256 locals are 21,719, 21,832 and 22,048, down from 23,163, 28,471 and 52,354. FeatureFlowValid.expand and FeatureListValid.known prove equivalence to the one-fact-per-local specification.

  • Native method-table loads check the index against the proved entry count (entryCount and counted on both table types). At 16/64/256 entries they cost 24,722/24,714/24,753 kernel heartbeats, previously 29,483/41,785/90,934. Cost remains linear in static bindings and the loaded index.

  • Class and static field instructions carry FieldRef. FieldRef.ofOperand? reads its owner, index, type and metadata name. Templates emit their links.

  • The compiled .NET 11 x64 Exception.set_HResult(Int32) setter writes four bytes to the bound field and returns the resulting caller memory. Its proof applies under program extension and additional fuel. Changing the store opcode or field token fails the body check.

  • ldarg uses Method.argumentAccess. argumentAccess_of_evidence proves unhomed narrowing. Outlines read parameter home slots directly. Starg, Ldarga and SlotOperations are deleted. 45 stepping rows stayed within 2%.

  • Instruction.ofRaw? checks ECMA-335 opcodes and their operands. The kernel checks the raw forms in Tests/ValueDecoding.lean. At 500/2,000/8,000 instructions, decoding costs 14,043/14,015/14,007 heartbeats per instruction.

  • ldftn and calli bind managed targets. Catalogs, stack slots and tail returns compare pinned signature structure. Seven caller extractions are byte-identical. The 400-byte owner proof passes. ManagedOp is deleted.

  • ManagedCallsValid checks ascending call-site keys in one pass. ManagedCallsValid_iff_original proves equivalence to the list check. Cost per site falls slightly at 64-1,024 sites. The old per-site scan grew 3.23 times at 64-256.

  • Tests/Objects.cs verifies its 38 example proofs in one generated batch, as 22 other test files do; locally the file went from 676 s to between 107 and 163 s.

  • The declared signature is checked by its own conjunct of MethodEvidenceValid, DeclaredValid, proved by rfl in the generated method{n}_declared_validated. On a 16-method fixture the shape theorems went from 4,211,835 to 774,006 heartbeats and the declared theorems add about 11,250 per method.

  • The object identity and null-test arms of Safety.step sit in its first match, so neither match exceeds the 79 alternatives split handles. The 91 generated step equations state the same facts. step_raise_faulting costs 7.1% more and has a raised heartbeat budget.

  • Method.ofRaw? uses Instruction.ofRaw? and the checked frame, signature and home computations. Method.ofBody? reads code and initialization from pinned bytes after checkBody. decodedProgram? does this for every method. Method.ofBody?_of_decodes uses the generated body check. At 500/2,000/8,000 instructions decoding costs 24,775/24,494/24,425 kernel heartbeats per instruction.

  • Examples/Proofs/DecodedAdd.lean proves correctness_decoded: the program that decodedProgram? reads from the bytes of Arithmetic::Add returns the sum of its arguments modulo 2^64. The proof names neither the emitted method nor the emitted program, and changing the add byte to sub in the extraction makes it fail. It costs 1.87M heartbeats and 479,000 kernel heartbeats, 1.38 and 1.24 times the proof over the emitted method.

  • localloc is a CIL instruction: Instruction.stackAlloc is deleted, the zeroing flag is DeclaredSignature.initLocals, which DeclaredValid ties to the localsinit bit of the body, and Instruction.ofRaw? decodes opcode 0xFE0F.

  • A call site states its method once, as a typed MethodRef (owner, metadata name, signature, generic arity and method arguments); the declaring type, return type and parameter types are read from it. checkCallOperand requires the name to spell the metadata row name, and the generic arity and method arguments to equal the row and the site. The name clause costs 41,199 and 151,448 heartbeats at 20 and 80 bytes, linear per byte.

  • Indirect accesses bind the raw width, signedness and alignment. All 39 forged emissions fail and all 25 extractor emissions pass. Unsupported ldobj and stobj types admit only the span no-op. Decoded cpblk and initblk execute directly. The 308 block checks cover alignment, bounds, overlap and zero counts. Lean proves a fill past the allocation cannot succeed.

  • Every raw opcode decodes to its admitted instruction or an explicit hole carrying the opcode. Stepping a hole faults. Instruction.ofRaw? and Instruction.ofRaw take the preceding instruction for prefixes. Instruction.ofRawCode carries it in one pass. Method.ofRaw? rejects undeclared arguments, Method.ofRaw?_code identifies the decoding at each pc, and ScalarFlowValid.instruction_checked proves the match.

  • fixedBytes joins chunks of at most 256 bytes through fixedDigitsWithin, avoiding kernel hash collisions on equal low 64 bits. At 125, 500 and 1,000 string tokens the body check costs 88,900, 92,700 and 99,800 heartbeats/instruction (previously 89,600, 136,300 and 201,500). The per-byte growth bound at 5, 10 and 20 KB is 1.15. Body obligations up to 256 bytes grew 0.06-0.46%. Binding pages use 512-byte chunks. A 4 KB page costs 23.26M heartbeats with equal chunk tails and 23.25M with random tails (previously 506.1M and 23.0M). Importing the prelude-only CIL/Extraction/FixedDigits.lean costs 1.92M heartbeats and 1.2 s for a generated audit module, down from 5.25M and 2.9 s. Tests/BodyLiteral.lean checks the import closure.

  • PrefixEntryFree forbids a branch or switch from skipping unaligned., volatile., tail., constrained., no. or readonly. at any pc. checkBody_prefixEntryFree, instantiateMethod_prefixEntryFree and MethodEvidenceValid.prefixEntryFree transfer this decoder guarantee to every validated method. prefixEntryFreeWith scans a branch-destination bit mask at about 1,380 heartbeats per instruction. Cecil extraction also rejects entry after a prefix. All corpus and fixture methods pass.

  • A homed argument is stored with starg, addressed with ldarga and read with ldarg; the lowered local forms for homes are gone, and the four raw forms decode. step_relabel_faulting is proved by splitting on the first match of step and costs 52,100 heartbeats where it cost 212,700.

  • Method.fieldShape and Method.valueShape resolve a typed field reference or a value type against the layout environment, with one generated fact per distinct operand that the kernel checks from one layout entry: 268,814 to 271,626 heartbeats per field fact and 13,294 to 16,135 per value fact from 8 to 512 structs.

  • Bare throw reads the evaluation stack. Null raises NullReferenceException, including across a branch. A live exception raises its checked runtime type. An unknown class leaves the CLR contract inconclusive.

  • The receiver fold is deleted: a raw stloc and ldloca before a span get_Length or get_Item call are emitted as themselves and checked against their raw instructions.

  • StepMetadata requires equal layout environments, and a method signature with an explicit receiver is refused in Lean by instantiation and by the metadata identity check; the declared signature check costs 9,883, 9,890 and 9,939 heartbeats per method at 1, 4 and 16 parameters.

  • Byte lists in generated evidence are numerals read by CIL.Extraction.fixedBytes instead of list literals: checking a generated file costs 29% (Add), 25% (Countdown) and 17% (Struct) fewer heartbeats in total, and the kernel part rises 3 to 6% because each check decodes its bytes.

  • MetadataName.ofBytes? reduces in the kernel in time linear in the name: 13,498, 35,148 and 119,302 heartbeats at 20, 80 and 320 bytes, where it cost 143,456, 1,746,460 and 26,147,681.

  • BindingAudit.metadataRows checks carried metadata and #US entries. A forged page fails. BindingAudit.staticData checks each static operand's Field, FieldRVA, signature, size, packing and mapped bytes. The table returns 17. A matching prefix, reversed bytes and a missing RVA marker fail. Deep results under --proof-root bind the compiled import closure. Failed publication creates no receipt or cache entry. TypeDef checks cover name, kind, fields, base and sorted NestedClass rows.

  • BindingAudit.publicKeyTokens checks Assembly keys and AssemblyRef keys or tokens against direct references. Malformed references fail even if others are missing. objectFields checks System.Object has no instance fields. tupleFields checks the pair TypeDef, both GenericParams and Item1/Item2 FIELD VAR signatures. Separate images work. Missing destinations leave facts uncovered. Rehashed Object fields and swapped tuple signatures fail. .NET 11 replay took 68.3 s and 79.9 s.

  • A support result is keyed by the extraction it was computed for, so a changed extraction no longer reuses the support of another one.

  • Count, Index and Required bind the live string at their checked ldstr site. The same proofs handle translated parameter names. The hole corpus rejects dead homes and dead prefixes except unaligned..

  • The extractor emits cil_decoded_method with Method.ofClosed? for every admitted method. The generated theorem identifies the complete method with the decoder result. The body certificate binds it to the selected assembly. Dead positions retain their raw opcode, and a reachable decoding refusal stops extraction.

  • Raw ldind and stind are the instructions ldind and stind over a numeric kind; load64, store64 and tableLoad are deleted.

  • ldnull, castclass and isinst are instructions with decode arms; objectTest and the memory operation nullObject are deleted. Method.ofRaw? decodes the instantiated code.

  • LayoutUse contains only struct constructions, locals and parameter homes. Canonical field instructions use the checked field reference. The same vector field resolves at byte 32 on x64 and byte 16 on ARM64. A swapped architecture table, owner or field type is rejected.

  • Struct ldflda uses the offset from its checked field layout. The offset-only Instruction.fieldAddress is removed. step_ldflda_struct_eq states the general step. step_ldflda_reference_eq and step_ldflda_readOnlyReference_eq preserve the receiver capability and use the checked pointer addition. Nested structs execute ldfld and stfld at the checked field offset and width. Both preserve padding flags. A store through a readonly reference faults even for a malformed value. Decoded ldfld and stfld now also replace fieldAt and setFieldAt.

  • Class and struct fields use ldfld, ldflda and stfld over FieldRef (opcodes 123-125). Method.fieldShape reads the checked layout. Instruction.instanceField? replaces classField?. Six class field operations, their checks and translator arms are deleted. Stores require the field's stack kind. Names come from metadata rows. Goals with .fieldAt 4 4 false or .setAggregateFieldAt 8 4 now name the field in .ldfld or .stfld. Across 35 extractions kernel heartbeats rise 0.78% and total heartbeats fall 0.05%.

  • Static loads, addresses and stores bind the owner, slot index, type, field name, static flag and storage descriptor.

  • newarr carries its raw type token and steps through the element shape the layout environment gives it; newArray and newReferenceArray are deleted, and a System.Object element array is refused by identity.

  • Call targets are read from each method's link table: the call arms of step take their target from the link of their pc and fault with unlinkedCall without one, and cil_instruction_equations states a link fact per call site.

  • step runs models through intrinsicCall, featureCall and related functions. MethodEvidenceValid.modelsAgree binds calls to typed entries using decoder and feature-flow evidence. memory_stepRenamed covers all memory operations. RuntimeModel.StepRenamed takes source well-formedness and an observable step. The 70 BitModels entries cover BitOperations, integer helpers and BinaryPrimitives.ReverseEndianness, excluding signed Log2 and signed 8- and 16-bit rotations. Outlines step the four bit counts through their calls.

  • Unsupported instructions and fuel exhaustion are inconclusive for CLR contracts. A verified refutation provides an input and initial memory satisfying the precondition, then proves a disallowed settled outcome or exhaustion at every budget. The theorem audit requires the corresponding Refuted statement and rejects a proof of bare negation.

  • Opcode 0x73 decodes to newobj of its constructor's MethodRef. This removes newAggregate, newObject, their translator records and step lemmas. The decoder and evidence share method{n}Links. ManagedCallsValid binds a live constructor to its raw site, target, class or aggregate link, bases and size. Tests reject a forged or missing link, wrong kind, base list, size, opcode or owner. Span and exception constructors keep their literal models.

  • Opcode 0x28 decodes to call of a MethodRef and CallPrefixes for tail. and constrained.. The reference gives the argument count and the link at the pc gives the target. Instruction.ofCallSite? handles call and newobj. Method.ofRaw?, Method.ofBody? and decodedProgram? take links after the environment. Method.withCode clears them. ManagedCallsValid checks the direct target and token. Extraction checks operands and prefixes for targets, imports and runtime models. Template code and link equations allow arbitrary callee indices. Only proof outlines build C# operation lists. Six compiled fixtures produced byte-identical extractions and outlines.

  • Typed runtime calls cover integer Math helpers (Min, Max, Clamp, Abs, Sign; 31 corpus and 44 example sites), Vector128.CreateScalarUnsafe and 128/256-bit GetElement on ulong (23 example sites). A model checks the operands it observes. Linked calls keep the guard in step_call_linked. reduceRuntimeModel resolves a closed method under a variable environment. step_call_intrinsic steps the resolved call. Earlier intrinsic rows used 32% fewer frontend and 71% fewer kernel heartbeats; virtual calls cost about 61,000 heartbeats per table entry.

  • Both reject forgeries. Zero quota fails at newobj. An unbound constructor is inconclusive. Unwinding keeps the object, HResult and caller writes. Callee storage expires.

  • The direct Instruction.intrinsic and its execution rules are removed. C# outlines no longer carry SpanEmpty, ObserveView, ViewQuery, SpanSource, SpanCreate, SpanFromReference or SpanSingleReference. Array spans retain the element, mutability and range an outline uses.

  • step_call_eq states a call step as callStep of the link at its pc, a regular definition, and every call-family step rewrites its link fact in the pass that applies its step equation. With a match on the link in the equation the kernel evaluated the table read once per site, and the calls stepping row cost 10,827, 16,474 and 47,170 kernel heartbeats per instruction at 16, 64 and 256 instructions. The row now costs 7,131, 5,397 and 4,963 kernel heartbeats (7,742, 5,800 and 5,315 before the conversion) and 801,548, 817,861 and 822,727 frontend heartbeats (821,255, 840,326 and 846,190).

  • The stepper rewrites the link fact of a newobj step in the pass that applies its step equation, so only the arm of the link's kind is simplified. The constructions stepping row costs 438,693, 395,870 and 385,510 frontend heartbeats per instruction at 16, 64 and 256 instructions (472,527, 433,397 and 424,162 before the conversion) and 6,825, 4,082 and 3,396 kernel heartbeats (7,299, 4,258 and 3,497). With the link fact one pass later the row cost 12 to 15% more than before the conversion.

  • Tests that read or rewrite generated method text go through shared helpers in Tests/GeneratedEvidence.cs, which forge a decoded method through its decoder call or through the raw definition the decoder reads. Every rejection test is kept: a forged decoder is refused by DeclaredValid, MethodShapeValid or ManagedCallsValid, and a changed raw instruction by ScalarFlowValid.

  • Lean decodes ldlen, newarr and numeric, reference and typed ldelem/stelem. Outlines read array views and Unsafe offsets from original CIL sites. Removed: arrayLoad, arrayStore, arrayTransfer, managed table operations, NewArray, ClassElement, TypedElementAccess, SpanLength, SpanSlice, SpanItem, ArraySpan, ArrayRange and AddOffset. Lean verifies typed RefillRead. Typed access rejects by-ref-like elements and requires pinned classes or System.String for objects. At 10 instructions numeric access uses 278,864 vs 278,242 frontend heartbeats/instruction. Typed access costs 6-8% less (256,343, 148,602 and 116,353 at 16, 58 and 254 instructions). Element proofs use step_ldelem_any_of_element, step_stelem_any_of_write and their transfer forms.

  • Opcode 143 decodes to .ldelema element readOnly; an adjacent readonly. decodes to .nop and sets the flag, and other pairings and branches into it fail. The step uses the checked element shape and arrayAddress; the extractor reads operand and prefix at the original site. ElementAddress, MemoryOp.arrayAddress, the lowered ArrayAddress, Arrays.ValidateReadOnly and the scalar readonly window are deleted. arrayAddress_of_element and step_ldelema_of_element replace step_arrayAddress_of_element. Address steps cost 4-8% less. At 512 sites no ScalarFlowValid row costs more: plain 277,254 vs 277,621, readonly 364,641 vs 396,905, block copies 471,028 vs 472,062. Extracted byte offsets roughly doubled those rows' generated bodies. The examples have 61 ldelema methods; the self-admission corpus has none.

  • DecodedSummary binds a contract to a decoded method, assembly pin, token and type arguments. DecodedAt checks the index, decoder result and reachability mask (Require DecodedAt to name a method decoded from the record #614). TranslationValid.direct_definition follows the original MethodDef, MemberRef or MethodSpec of an ordinary live call to the selected callee MethodDef row and assembly slice. Two compiled DLLs use the same token. Changing only the callee pin fails. Scalar and byref callers reuse summaries. At 16 calls the proof costs 52.1M elaboration and 621,945 kernel heartbeats, versus 158.4M and 3,228,438 for stepping. Tests check scaling, footprints, preconditions, definitions and tokens.

  • An instance field access whose owner has no carried definition is refused in Lean (unboundInstanceField). Before, the operand check accepted any field name at index 0 for a type of an unpinned assembly or of a contract import, and no other check bound the index to the field the token names: a forged extraction in which ldfld of one field read another field's offset passed the whole evidence check, on the struct path and on the class path, and only the extractor refused it. Item1 and Item2 of the core-library ValueTuple pair keep indices 0 and 1. All 5,065 instance field accesses in the admitted corpus have owners in the module itself.

  • Lean admits System.Object and generic class instance fields and checks each generic head's class kind against metadata, covering 45 corpus methods (88 entries). A generic owner's arity is tied to its GenericParam rows: an owner without parameters carries the adjacent rows that bracket it, so Lean, not only the extractor, refuses a parameterised definition named without arguments. This relies on the ECMA-335 owner sort order, which no check reconfirms yet. A signature without the GENERIC flag has no parameters, as before. Over 60 corpus extractions the brackets cost 1.7% of heartbeats (tables 16%, body check 2.3%). Tests/SelfAdmission.cs has an opt-in mode checking every admitted entry in Lean (about 2.7 CPU-hours; no suite runs it); on 290e747f Lean accepts all 3,760 admitted corpus methods.

  • The generated method{n}_calls_validated theorem is decided in the kernel on ManagedCallsValid, which reads links by one walk. The earlier tactic went through a list form that read each pc's link by a table scan, so its cost grew with instructions times links: 24.1M heartbeats at 125 string tokens and 159.4M at 500. It now costs 3.1M and 9.0M, and the lookups rows bound the whole file and the call check per token at 1.15 (strings 1.04, fields 1.09, calls 1.07).

  • The generated feature theorem states its link lookup as MethodEvidenceValid does. With the two stated differently, assembling the evidence theorem unified them by unfolding the decoded body, about 390,000 heartbeats per instruction; it now costs about 395,000 at 502, 1,002, 2,002 and 4,002 instructions. cil_decoded_method writes an all-zero struct local as List.replicate size 0, the term a literal definition has, so a caller's goal after frame entry is unchanged by decoding.

  • The System.Object constructor is the first runtime-model entry. A constructor's base call stays one unlinked .call, where the extractor lowered it to pop. A modelled call states no link and an unmodelled one the link the call check required; ManagedCallsValid takes the modelled set and decides both in one match on the instruction, costing a non-call pc about 79 heartbeats. callEmitsNoPop in UnsafeCallsValid refuses pop at a call or construction site, and the runtime catalog lowers nothing. Stepping a base call costs 18-25% fewer frontend heartbeats than pop at 16, 64 and 256 instructions, and call stepping rows 5-9% fewer kernel heartbeats. Model facts are proved per entry, so a new entry adds a case. This defines 791 more corpus methods from their decoder.

  • Static sites bind each instruction to the exact FieldRef in its storage descriptor, including field ldtoken. Lean refuses an absent owner, except for the platform constant required by the feature check, and an instantiated static owner. StaticIdentitiesValid in TranslationValid uses oneToOne_spec to bind fields and identities in both directions. At 8, 32 and 128 sites it costs 22,544, 20,876 and 22,706 heartbeats per site. An instance operand with a missing owner reports the reason.

  • Program.closure follows method links. MethodContract.Holds.restrict moves a contract to its closure and DecodedSummary.relocate to a matching program. The closures suite reuses one proof in three programs and rejects different target bytes. Program.closure_eq_closureWith permits any lookup agreeing with the list. Extractions certify programLength, programIndex (a balanced tree from program_index%) and programIndex_get? in one kernel comparison. Finding n methods and e callees in a program of P takes O(n log P + e). Chains of 8, 32 and 128 methods cost 87,394, 335,656 and 1,422,953 kernel heartbeats (list lookups cost 90,395, 437,519 and 3,533,840). Four reachable methods in programs of 128, 512 and 2,048 cost 55,819, 58,512 and 61,237 (lists cost 81,699, 179,818 and 571,795). The index adds 0.49% to elaboration for Add and 0.10% for 128 methods.

  • DecodedSummary.reprofile binds the same evidence and method identity to an agreeing profile. Independent x64-v3 extractions reuse compiled scalar proofs of addition, a low vector lane and an eight-byte byref write. Both extractions and proofs replay together. A different addition token or add byte invalidates reuse. Re-exporting the same DLL with a +1-or-+2 postcondition changes both closure and interface digests. The cached exact caller fails and the weaker caller verifies against the new digest.

  • Reversing the single branch in compiled Choose preserves both two-instruction return regions. A consumer imports their compiled proofs, checks the changed branch, and proves its result for every Boolean, word pair and caller memory. The consumer cost 2.38M frontend and 285,524 kernel heartbeats. Direct stepping cost 2.79M and 126,232. Compiling the reusable producer cost 8.20M and 197,560.

  • The changed CountCalls initializer starts at one. A consumer reuses the compiled loop invariant, decreasing measure and Decrement proof to prove x + 1 modulo 2³² for every input. The four modules replayed together in 7.0 s.

  • The vector example: DivisionIntrinsics.UnsafeLowNext returns UnsafeLow(x) + 1, and Examples/Proofs/VectorSummary.lean proves it once by stepping through UnsafeLow and its two modelled vector calls and once from a DecodedSummary of UnsafeLow. Stepped it costs 3,192,215 heartbeats (118,705 in the kernel, 3,488 proof objects); through the summary, with the summary's own proof, binding and decoding, 3,506,999 (139,650; 4,614), so one use of a callee this small does not repay the summary. main has no proof of a caller of UnsafeLow to compare with. A forged UnsafeLow that reads the other lane is refused by the body check.

  • Segment contracts (CIL/Safety/SegmentContract.lean): a precondition, a memory footprint and a postcondition over checked exits, with sequential and branch composition and links to weakest-precondition proofs.

  • The stepping tactics keep an index of the equation hypotheses in scope, so the cost of a step no longer grows with them (21 to 61 heartbeats per hypothesis per instruction between 16 and 256 hypotheses), and snapshot walks restate a fixed number of facts per store.

  • Path comparison in the verification scripts follows links and uses the case rule of the volume that holds each path, read from the operating system.

  • An x64 profile below the .NET 11 x86-64-v2 baseline is rejected, and the x64-sse2 profile is removed.

  • StrictBinding: methodMetadataBound and MetadataRowsBound bound the carried rows of a method across pages.

  • Closed argument storage is decided without Classical.choice; that check costs 57% less on Add and 44% less on Countdown.

  • Metadata names, user strings and assemblies use typed values. ldstr preserves UTF-16 and accepts ECMA and .NET Latin-1 flags. A changed surrogate byte refutes the return contract. Any translation preserves the folded exception type and argument count. Both DLLs share one proof. Some scopes compare text.

  • The reference interpreter CIL.step itself gives a mixed int32 and native-int operand pair its ECMA-335 III.1.5 result for sixteen instructions (arithmetic, bit operations, comparisons and signed branches); Safety.step reaches the widening only through it, and Tests/MixedNativeOpcodes.lean proves the two interpreters agree for every operand, both orders and any stack beneath. Unsigned branches still refuse a mixed pair: on .NET 11 the runtime zero-extends or sign-extends the int32 operand of a mixed unsigned branch depending on whether the JIT has it as a constant, and one method changed its result after tier-up, so no single rule matches the runtime.

  • Execute mixed native arithmetic and reference offsets through the bare opcodes: add on a reference and an integer keeps the checked byte-offset semantics of the form it replaces, and Tests/ReferenceTests.lean proves the two equal and rejects the old lowering. add on a native method table and an integer offset, in either order, executes the checked cursor addition; ManagedOp.tableOffset and the C# TableOffset record are deleted.

  • Use opcode-specific arithmetic, conversion and local instructions. Local narrowing comes from declared metadata. Checked return dispatch rejects incompatible narrowing; execution and structural proofs use the shared dispatch. Remove unused vector-home components and dead block helpers.

  • Integrate deep checks into the internal standalone verification path. Retain pinned image snapshots, build StrictBinding in the selected certified library, jointly replay and audit the proof and binding contributions, and include binding evidence in successful reports. verify --deep-checks exposes them, and replay failures are attributed to the declaration that the kernel rejected.

  • StrictBinding checks the carried table header, decoded header, Assembly row and its string and blob entries against the pinned image (assemblyMatches_of_assemblyBound). For slice rows, RowsMatch, rowsBound and rowsMatch_of_rowsBound mask MethodDef RVAs and reject missing or unused heap entries. One sort and merge-join assigns heap keys. Cost per added row grew 1.07× from 256 to 1,024 rows. The corpus covered 88 methods and 949 rows across eleven tables. Metadata roots accept a 256-byte version field.

  • Check pinned SHA-256 digests and PE method-body locations with paged body claims and flat image-list auditing. Validate original library bytes and file sets before cache promotion, including same-length changes with restored timestamps.

  • Keep pinned metadata contexts alive through contract import/export, source-bundle verification, inventory probes and exception linting.

  • Read the metadata table header through the stream directory and the Valid mask, and refuse an uncompressed #- table stream and malformed roots, each with its own error. Carried MethodDef rows keep the body address zeroed, so editing one method leaves the evidence of other methods byte-identical.

  • Every Lean test library has a suite that builds it: 19 libraries that only an all-library build reached are now built by core, evidence or intrinsics, and Tests/Strings.cs, Tests/Identities.cs and Tests/StrictBindingFixture.cs run in a suite.- Build with .NET 11. Share hash operations and reduce repeated work in stepping, embedding, metadata lookup, extraction and audit preparation.

  • BodyDecodes.callManagedTarget resolves a raw operand to a slice and MethodDef. For explicitly scoped owners, DecodedAt.direct_site identifies the callee pin, token and type arguments. App.Direct and Lib.Step share a token. The caller resolves to Lib, rejects App's pin and preserves caller memory through the summary.

  • Fresh, cached and compile-only verification bind the SHA-256 of the exact identity.json bytes accepted by the extraction check.

  • Add, branch, generic, struct and array proofs pair refutations with positive contracts. A weaker array clause breaks the pair. Loop contracts check divergence and wrong returns.

  • Profile templates and gate program comparison read a multi-method bound extraction: its decoder inputs carry the pins, platform table, constructor image, each bound caller's source and binding, and the appended CoreLib rows, and the templates command binds each row's callees, including the image's getter declarations. The pool suite binds shared templates to all nine of Rent's methods in scalar and x64-v3, and the gates suite certifies Rent with a changed message and refutes a null-pool return and Second's sub changed to add in the kernel (Profile templates and gate decoder inputs refuse an extraction with a bound construction #627). Extracted.lean is byte-identical.

  • Removed extractor and verifier members nothing calls (frame Lean writers, StaticSite.ToLean(), ExceptionClauses.Protects, UserString.Units, Slice.Module, ConsumerInputs, ImportedBindings) and scripts/PrepareConsumer.cs; the core suite now builds Tests.DecodedSegment and Tests.LoopSummary.

  • Object outlines that carry a fact across an allocation name the empty footprint instead of an undefined Nowhere (Cover object outlines that carry a field fact across an allocation #638 adds a fixture).

  • Platform definitions and the platform table are keyed by typed AssemblyName, and checkedReferenceScope, PublicKeys and the strict binding image lookups select images by AssemblyName equality; the scoped platform lookup costs about a third of what it did. TypeExpr.atom carries a HeadKind (value, class or interface) that admission checks against the TypeDef row or platform definition, so a class and a struct of one spelling are different types; before this, a class's atom with struct receiver facts was accepted as an aggregate construction, and Tests/ExtractionGenerics.lean now refuses it. Consumer-visible: TypeExpr.atom takes a HeadKind, TypeExpr.spelledModified is new, PlatformDefinition holds assembly : AssemblyName, exceptionOwner? matches class-headed atoms, and the contract sidecar records each atom's head. Shared tactic tests change by at most +0.06% (Compare types by typed identity in every extraction check #610).

  • Removed 14 Lean modules and 157 declarations under CIL/ that nothing references after the move to canonical CIL (about 1,470 lines), including the LiveValues re-export and unused consumer step helpers; tagged simp and step lemmas, lemmas whose names tactics or the extractor build from text, and documented results stay.

  • An atom from an assembly that is neither pinned nor platform takes its head from the signature's value-or-class marker, and Lean still refuses it through externalNamed, so methods that name such a class and contract imports of unpinned libraries extract again. ContractType carries a non-nullable TypeHead with a None case (Compare types by typed identity in every extraction check #610).

  • Removed Tests/canonical-methods.txt (3,472 lines), a byte-identical copy of Tests/SelfAdmissionBaseline.txt; the blockers suite now requires every admitted self-admission method to be extracted, and the examples' list moves to Tests/ExampleAdmission.cs with Tests/ExampleAdmissionBaseline.txt. Removed the guard against the deleted outline types, renamed Tests.LoweredCallRefusal to Tests.CallDecoding, and rewrote docs that described a lowered emission.

  • Removed eleven checks that another check already makes at the same strength (scalar evidence, metadata identity, runtime model, strict binding and deep examples, a second 128-method closure measurement, a second build of the layout accumulation library, and repeated intrinsic contract verifications); each commit names the check that still covers it.

  • An imported call's owner takes its head kind from the TypeDef of the verified import library, and Lean checks it against the typed export's signature (Compare types by typed identity in every extraction check #610).

  • Validators that only re-checked the decoder against itself are removed, each recovered by a theorem: the code-equation conjunct of MethodEvidenceValid (MethodEvidenceValid.code_eq), featureOpMatches at fold sites whose role fixes the instruction (Instruction.withSiteDecoder_role), the duplicated indirect window in the feature pass and the value encoding comparison at type fold roles (MethodEvidenceValid.indirect_checked, scalar_checked, feature_checked). Checks that do typing, metadata or resolution work stay. Whole-extraction checks cost 0.4 to 0.7% less, and the shared tactic tests are unchanged. Consumer-visible: MethodEvidenceValid has one conjunct fewer, method{n}_scalars_validated states ScalarFlowValid alone, FeatureFlowValid.instruction_checked takes a codeDecodes hypothesis, and ScalarFlowValid.folded_checked is removed (Emit canonical CIL and metadata without constructing specialised executable instructions #582).

  • The cli and lookups suites run their independent checks concurrently, admitting a child process only while the running ones stay within one per processor and nine tenths of the memory .NET reports, with measured reservations per check; checks that time Lean still run alone. Locally lookups takes 522 s where it took 2,868 s and cli 909 s where it took 2,605 s; with .NET limited to four processors and 14 GiB they take 1,206 s and 1,388 s. Sizes, limits, profiles, mutations and assertions are unchanged.

  • A single caller's bound constructor package is written by cil_evaluated as a checked literal, boundPackage, with boundPackage_eq : managedPackage = some boundPackage proved once in the kernel, so later checks and consumer proofs read the literal instead of evaluating the CoreLib binding again (about 6 s each). Locally the evidence suite's Throws stage takes 560 s where it took 2,142 s, and the suite 3,479 s where it took 5,057 s. Examples/Proofs/Percent.lean reads boundPackage.

Remaining work

Not verified

  • The suite cost records in scripts/verification-durations.json give cli 193 s at the merge base and 1,501 s at this head, and workspace 272 s and 236 s; Measure the costs PR #602 left unmeasured and attribute its suite-time growth #635 attributes the growth.

  • Transfer and unaligned memory passed. TupleSize binds both argument scopes. DivRem passed 500 hardware and 562 Math cases. Both remainder mutants give 1 for 7 / 3.

  • Matched 12 arithmetic, 26 branch, 14 vector/profile, 11 guard/endian and 38 memory outcomes.

  • Resumptions add 0.14-1.22% frontend heartbeats to field and intrinsic stepping. Unmeasured costs include the run_succ premise on the shared tactic tests, the merged hole/localloc/starg/ldarga steps, managed-call structural checks, StoreFacts and loops after typed exceptions, and the linked first pass for instance, virtual and managed calls. Stepping rows cover call only.

  • Managed-call heartbeats/site at 64/256/1,024 sites are 16,061/14,352/13,924. At 256 sites, table shape costs 1,650/site, zipped traversal 4,050, first link read 2,560 and link fit 2,200.

  • Debug self-admission can accept an empty baseline (Keep Debug builds of the extractor out of Extractor/bin #624).

  • The closure benchmark excludes index construction. Static steps lack site facts. Class ldflda is refused. MethodSpec argument counts are checked against the declaration.

@benaadams benaadams added feature Adds a capability area: proofs Lean proof API, contracts and tactics labels Nov 14, 2026
@benaadams benaadams changed the title feat(extraction): check extracted methods against their decoded CIL bytes feat(cil): add decoded body checks, metadata binding and typed identities Nov 14, 2026
@benaadams benaadams changed the title feat(cil): add decoded body checks, metadata binding and typed identities feat(cil): add decoded body checks and typed metadata identities Nov 14, 2026
@benaadams benaadams changed the title feat(cil): add decoded body checks and typed metadata identities feat(cil): check decoded bodies and typed metadata identities Nov 14, 2026
@benaadams benaadams changed the title feat(cil): check decoded bodies and typed metadata identities feat(cil): validate decoded bodies, metadata and deep proof bindings Nov 14, 2026
@benaadams benaadams changed the title feat(cil): validate decoded bodies, metadata and deep proof bindings feat(cil): migrate execution and proof bindings to decoded CIL Nov 14, 2026
@benaadams
benaadams force-pushed the feat/canonical-cil branch 2 times, most recently from 7d392ae to 6f13572 Compare November 17, 2026 14:49
Tests/ScalarEvidence.lean stated four examples that another example
already checks at the same or greater strength:

- The value-array stfld refusal of two objects appeared twice in the
  same section with the same definitions; the first copy stays.
- MethodEvidenceValid for addEvidence by decide +kernel appeared twice
  back to back; the first copy stays as the kernel counterpart of the
  refused elaborator decide.
- (encodeBody scope addRaw).isSome by decide +kernel repeats the plain
  decide example above it, whose proof the kernel also checks; the plain
  decide copy keeps the elaborator budget it asserts.
- scalarOpMatches of add over int32 and native int is the first conjunct
  of addition_admission in Tests/MixedNativeOpcodes.lean, decided on the
  same instruction.
- Tests/Identity.lean evaluated PrimitiveType.int32.elementType alone;
  the kernel example over every primitive's element type code in the
  same file includes int32 at 0x08.
- Tests/Identity.lean guarded the display of MetadataName.mk 767 a
  second time; the #guard_msgs #eval of the same display stays beside
  the other malformed-code displays.
- Tests/MethodBinding.lean guarded code equality of a relocated tail
  call; the next guard requires firstCodeOrLinkDifference of the same
  pair to be none, which holds only when the code lists are equal and
  also compares the links.
- Tests/MetadataBinding.lean rejects_a_duplicate_token repeated the
  MetadataSlice.index duplicate-key refusal; the theorem of the same
  name in Tests/MetadataDecoding.lean checks that function on a slice
  with a repeated row and pins the reported token. The refusal depends
  only on key order, not on the row bytes of either slice.
- Tests/RuntimeModels.lean guarded that the aggregate snapshot store
  and skipInit succeed; the equalities above them already state each
  result as .ok of a given frame and memory.
- Tests/ExactIntrinsics.lean stated, for each of call0 to call8, that
  runtimeModel is not the same intrinsic at another arity or not a
  neighbouring intrinsic. Each keeps example decides runtimeModel ==
  some of the exact model, and RuntimeModel derives DecidableEq, so it
  implies every one of those inequalities for the same call site.
The lookups suite built Tests.LayoutAccumulation with its other test
libraries, and the evidence suite compiles the same module because
Tests.ImportedLayouts, one of its prepared fixtures, imports it. The
evidence suite now runs those checks alone; suite selection follows the
import, so a change to the module still selects evidence. The lookups
description in scripts/VerificationSuites.cs and docs/VALIDATION.md no
longer lists the library.
ClosureCosts stated and decided the closure of the same 128-method chain
twice, as the last chain sample and the first long chain sample, with
the same program, index and statement under two names. A program that
two shapes share at one size is now stated by the first shape that lists
it, and the long chain reads that cost. The chain (8, 32, 128) and long
chain (128, 256, 512) growth checks keep their three sizes and the 1.15
limit.

`LookupScaling.cs --closure-only` passes: the long chain reads 1,424,616
heartbeats at 128 from the chain sample and grows 1.02 times per unit.
- Tests/StrictBinding.lean sha1_empty proved the empty-message SHA-1
  digest; Tests/Crypto.lean empty_digest proves the same statement on
  CIL.Crypto.Sha1.ofBytes in the core suite, without the image audit
  library.
- Tests/StrictBinding/Container.lean fixture_container_decodes proved
  that the fixture's container and tables decode; the theorem above it
  proves that facts of the fixture, which runs the same ImageView.ofImage
  and decodeMetadata first, equals the expected facts.
- CheckBindingDecoding in Tests/StrictBindingDecoding.cs compared the
  checked-in fixture module with the module its image generates;
  Tests/MultiAssembly.cs runs Tests/StrictBindingFixture.cs, which makes
  that comparison, earlier in the same assemblies suite.

The assemblies suite passes.
CheckTypeDefinitionScaling proved StrictBinding.prepare of each image
twice, once in its Types case and again in its Sorted case, only to
subtract the same preparation cost from both checks. The Sorted case now
reports around its check alone and subtracts the preparation its Types
case measured on the same Types.pinned term. The type definition growth
limit and the NestedClass per-row growth limit apply to the same check
costs as before.

The assemblies suite passes.
Tests/DeepSession.cs required DeepCheckInputs.MatchPins to refuse an
identity whose one reference has a digest no input line states. The
same refusal, with the same "No line" marker and an exception type
check, is in Tests/DeepCheckInputs.cs, which the assemblies suite runs
before DeepSession; MatchPins throws before reading any image, so the
real extraction DeepSession used does not reach another path.

The assemblies suite passes.
The byte shuffle and sign window loops called VerifyContractVariant once
per counterexample, so the Shuffle256 contract was extracted and proved
twice and the SignWindow contract three times with the same entry,
proof, profile and imports. Each loop now runs its runtime comparisons
first and then calls VerifyContractVariants once, which verifies the
positive statement and checks every counterexample against it.

The AVX-512 Less mutant check also invoked the original Less on the
unsigned high-bit witness; the Less (1, 1 << 63) row of the exact
intrinsic table makes that call under the same host condition and
requires the same 255.

The intrinsics suite passes.
- accepts_the_method_definition_its_row_gives required identity own.1
  mainMethod to succeed; names_spell_the_owner_the_method_states, in the
  same file with the same definitions, is true only in that success
  branch and also checks the names it returns.
- rejects_a_field_access_that_disagrees_with_the_field_row stated the
  ldfld check of countOperand twice: Tests/MetadataWorld.lean defines
  countOperand as the field operand the fourth conjunct spelled out.
… tests

Tests/StrictBinding/Slice.lean accepts_other_assembly bound the Assembly
block of the image with a changed major version to that image.
Tests/StrictBinding/Metadata.lean blocks proves assemblyBlockBound,
which locates the same image under the same identity and then runs the
same assemblyBound, for that block and the fixture's own block. The
otherImage definition only served the removed theorem; the docstring of
otherAssembly names where its acceptance is proved.
… import (#610)

The parent TypeRef of a MemberRef carries no value-or-class marker, so an imported
struct owner, such as InitializationFixture.Word, was written as a class atom. Lean
compares the call site's owner with the owner of the import's typed signature, so
the mismatch failed body decoding with operandMismatch and ManagedCallsValid.

PinnedAssemblies keeps each verified import module by its assembly identity, and
HeadKind reads a type of an unpinned assembly from that import's TypeDef. The
module is the implementation whose SHA-256 and interface digest the import was
checked against. A type of an unpinned assembly that no import defines keeps the
marker; Lean refuses such an atom since no platform definition names it.

SOUNDNESS-EVIDENCE describes how an imported call's owner is matched. Self-admission
and canonical methods are unchanged. No Lean changed.
…equation (#582)

MethodEvidenceValid already requires closed decoding to produce the record, so the separate
code equation conjunct duplicated it. MethodEvidenceValid.code_eq now derives the equation,
and the generated instruction checks no longer carry it.

The feature check no longer compares the instruction at a fold site whose role fixes the decoded
instruction, nor applies the indirect access window the scalar check already applies. The scalar
check also skips the raw value comparison at type fold roles. FeatureFlowValid.instruction_checked,
ScalarFlowValid.instruction_checked and ScalarFlowValid.indirect_checked recover the skipped
comparisons from the decoded code, through Instruction.withSiteDecoder_role.

Forgery tests that relied on those duplicate checks now state the refusal through the code
equation.
…alidated record (#582)

MethodEvidenceValid.feature_checked, scalar_checked and indirect_checked discharge the decoded code
hypothesis from the record's own code equation, so each comparison the validators skip holds for
every validated method.

The kernel-decided code equation that refuses a forged emitted instruction is shared from
GeneratedEvidence as DecodedCode. The throw fixtures use it for a forged raised type, which the
feature certificate no longer compares at a folded throw, beside a control on the genuine code.
… extraction (#582)

The null case narrows its source to the feature obligation, which drops the decoded code
obligation the forged raised type is refused by.
… its identity (#610)

Registering a second import image with the same assembly identity threw on the
duplicate dictionary key, which stopped the constrained resolution cost check
that registers many such images. The images of one identity are now kept
together, and a type's head is read from an import only when exactly one
registered import has its scope's identity; otherwise the signature's marker
stands, and Lean compares the owner with the typed export as before.
The deep CLI stage ran its checks one after another; its 50 CLI calls, 28 of them
deep verifies, made it 1,377 s of the cli suite in CI. Its independent checks now
run at once: the binding text, platform image and consumer checks in one sequence,
and the package evidence, platform pair, dispatch catalog, publisher key, layout,
generic constraint, enum storage and static table checks beside it. The dispatch
catalogs check its two assemblies and the two-assembly catalog at once.

Concurrently runs checks on their own threads. Execute admits the child processes
they start one per processor while their reservations fit in nine tenths of the
machine's memory, larger reservations first. A process reserves 3 GiB unless its
check reserves a measured peak; a verify whose joint kernel replay is rejected
reserves 20 GiB and runs alone on a 16 GB runner.

The publisher key check reads its own copy of the digests, since the platform
checks rewrite the shared file. Builds with a project reference and lake builds in
the checkout package run one at a time.
…ry bound

The lookups suite ran 185 Lean files one after another, 2,479 of its 2,575 s in CI.
The checks that time Lean (model table, closure and opcode decoding) and the library
builds still run first and alone. Every other check then runs at once under the
bounded admission of the cli suite, and each check's sizes run at once where its
assertions compare them only after all are measured.

Lean runs whose peak working set exceeds the default reservation reserve 5 or 9 GiB:
the largest bodies, string and field token sets, sparse links, decoded methods,
address checks and local slots. Heartbeat counts and growth limits are unchanged.
A verify's reservation covers its whole process tree: the extractor, its Lean runs
and the kernel auditor. The dispatch catalog verify peaked at 3.3 GiB on Windows,
above the 3 GiB default, so every deep CLI check now reserves 4 GiB unless it
reserves more. The checkout package is prepared before the checks share it, since
its first use writes its lakefile.
… checks start

One lookups run failed when the Flags fixture build exited 1 after restore
with no MSBuild diagnostic, at the instant seven extractor processes started
beside it. The failure did not recur in 260 rounds of the same launch shape,
so its cause is unknown. TemplateChoiceCosts and LayoutIdentityCosts now build
their assemblies before returning their measurements, so no dotnet build runs
beside a concurrent check. The fan-out call also wraps to 120 columns.
A single-caller extraction defined boundPackage as managedPackage.get, so every kernel
check that read the package (translation_valid, signatures_length, program_method0, each
invoke in a consumer proof) evaluated the CoreLib constructor binding again, about 6 s
each. cil_evaluated now evaluates an Option-typed term with compiled code, writes a
ManagedPackage as a literal that names the extraction's own inputs, and proves
boundPackage_eq : managedPackage = some boundPackage once in the kernel. The literal is
not compiled; compiled code runs managedPackage instead.

Examples/Proofs/Percent.lean and Tests/CompiledPercent/Proof.lean read boundPackage and
use boundPackage_eq where they stated the physical package.
Describe where the kernel evaluates and checks a bound package, how to time a bound extraction
and its boundary proof, and reference figures for Percent.
A package that cil_evaluated writes names the original, body and profile definitions of its module
rather than repeating their values; the test fails when the literal stops naming them. The binding
guide states which values a bound package names and where its compiled code comes from.
Rerun the profiling commands on the extraction the current extractor writes and record its kernel
times.
The commands joined LEAN_PATH with ':', which fails on Windows; they now choose the separator by
platform. The reference figures are the range over four runs. The evidence guide states that a
single caller's boundPackage is the derived package, tied to it by boundPackage_eq.
…olvable names

The documentation check probes a code span that is wholly a snake_case word as a
library declaration. The bound package description cited the placeholder name_eq
and the generated translation_valid that way; it now states the equation with its
statement and qualifies the generated theorem by its Extracted namespace.
@benaadams
benaadams marked this pull request as ready for review November 26, 2026 15:52
@benaadams
benaadams merged commit ab3a3ee into main Nov 26, 2026
25 checks passed
@benaadams
benaadams deleted the feat/canonical-cil branch November 26, 2026 15:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment