Repository navigation
Conversation
benaadams
force-pushed
the
feat/canonical-cil
branch
from
November 16, 2026 02:22
b0fac33 to
2d85785
Compare
Tests/ConsumerVerification.cs includes Tests/GeneratedEvidence.cs since its component check forges a decoded helper through the shared helpers, so a change to the helpers selects the core suite as well. The selection test states that.
The elements bodies load and pop an int32 element of their array argument and store their index argument into it per cycle, each access stepped from one supplied element fact. The row gives array element access a stepping cost to compare against as its instructions change form. VALIDATION now also lists the constructions bodies, which the suite already measured.
…on branch Merges feat/canonical-cil at fee86cd, which holds the newobj conversion. Both branches replaced lowered call-family constructors with CIL-shaped instructions over a typed MethodRef whose target is the link at their pc; each conflict keeps one form: - Instruction.ofCallSite? decodes opcode 40 to .call and 115 to .newobj, replacing callOf? and construction?; Method.ofRaw?, ofBody? and decodedProgram? take the link table after the environment, as the newobj branch ordered them. - Instruction.statesLink names the instructions whose table states their link (call, newobj); readsLink is link?.isSome || statesLink, replacing the newobj branch's link?.isSome || constructs. - validateLinkedCallWith checks a construction with validateConstructionWith and every other instruction with linkFits and validateManagedCallWith; ManagedCallsValid_iff_original is the one list-form theorem (linkAt_eq, ManagedCallsValid_of_implied and all3_implied are dropped), and ManagedCallsValid.linkFits excludes constructions. - The step arms, relocation, append-locals, guard, flow and fixed-step exclusions keep both the call and the newobj arm; tail calls exist only as the tail prefix of call. - reduceArgumentCount and reduceParameterCount share closedOperandCount?, so a call's argument count and a construction's parameter count reduce by one mechanism. - The extractor emits the newobj branch's named table method{n}Links for every method; a call's operand is the typed MethodRef from MethodReferenceOf, as a construction's is, and the constrained prefix's type still comes from the closed evidence. FirstDecodeRefusal has one Translated kind for a call or construction the decoder would not give. - Tests keep every rejection of both branches; the value decoding table and its forgeries hold both call and newobj rows; Tests/MethodBinding and the docs state that withCode drops call and newobj links. Recorded files (Tests/canonical-methods.txt, Tests/SelfAdmissionBaseline.txt, Tests/HoleCorpusBaseline.txt) are feat/canonical-cil's. Cost rows, kernel heartbeats (stepping also frontend), before the merge and after it: | Row | Before | After | | --- | --- | --- | | call check per site (64/256/1024) | 14977/13391/12994 | 14906/13311/12913 | | decode raw per instruction (500/2000/8000) | 14041.1/14012.9/14005.5 | 14042.8/14014.7/14007.4 | | method decode per instruction | 24784.2/24503.9/24434.9 | 24774.6/24494.4/24425.4 | | decoded definition per instruction | 26307.2/25713.7/25469.9 | 26311.9/25718.4/25474.6 | | calls kernel (16/64/256) | 7644/6151/5777 | 7644/6151/5777 | | calls frontend | 784572/798844/803377 | 784555/798828/803360 | | tablecalls kernel | 7644/6151/5777 | 7644/6151/5777 | | constructions kernel | - | 6822/4082/3396 | | constructions frontend | - | 438610/395838/385551 |
… equation The linked step dispatch covered only newobj; every call-family opcode (call, callInstance, callVirtual, newobj, managed) now takes cil_checked_linked_step_by_equations, so the link fact rewrites in the first pass and simp simplifies only the linked arm. Without a generated link fact a supplied one that states body.linkAt pc enters the first pass too: a call's equation names callStep, whose arms the second pass does not rewrite, so Tests/Automation's opaque_numeric_call failed with a supplied link before this change. Stepping rows (16/64/256 instructions) before and after: | Row | Before | After | | --- | --- | --- | | calls kernel HB | 7644/6151/5777 | 7131/5397/4963 | | calls frontend HB | 784555/798828/803360 | 801534/817846/822712 | | calls proof bytes | 16144/13200/12465 | 14214/10762/9899 | | tablecalls kernel HB | 7644/6151/5777 | 7131/5397/4963 | | tablecalls frontend HB | 784552/798920/803607 | 801552/817881/822853 | | constructions kernel HB | 6822/4082/3396 | 6822/4082/3396 | | constructions frontend HB | 438610/395838/385551 | 438606/395833/385546 | Kernel heartbeats fall 7-14% and proof bytes 12-21%; frontend heartbeats rise 2.2-2.4%.
Lean bound an extractor `.object` to any class-like type, so a forged extraction could name an interface, System.Object or an external class as an array element, generic argument or type operand. stelem.ref decides a store by the stored instance's lineage, which never lists an interface, so for an interface array the model would claim an ArrayTypeMismatchException the runtime does not raise. `objectNamed` now requires a class of a pinned assembly or System.String. The type a class instance field holds keeps the class-or-interface rule (`Frame.admitsHeld`), since its slot is never read through. The extractor's reference-array elements narrow to the same set: an array of a class outside the pinned assemblies other than string, such as StringBuilder[], is refused as an unsupported array element type instead of admitted as an array of opaque references. Self-admission is unchanged: 3,742 of 13,284 entries admitted and 2,595 of their 3,742 methods decoded, with the same first-refusal table. The metadata world gains an interface and a reference to System.String, and the binding tests check each path an element type takes: type operands, array locals, call-site generic arguments, owner instantiations and the types class fields hold. Each refused case was admitted before.
The scalar transfer admits a managed handler table only to ldlen and to ldelem.i or ldelem of the table's own pointer type at an int32 or native index. These cases state each refusal: other index kinds, another signature, a non-pointer or missing type operand, the sized loads, ldelem.ref, ldelema, every store, and a native table cursor in the table's place. They read the raw instruction and stack kinds only, so they hold for whichever instruction form the extractor emits.
…dex tests Call.Site is now the MethodRef the raw operand names, so the reflection fixtures set one and expect its term in the rendered call.
No step needs it: a newobj step reads constructor.parameters.length as feat/canonical-cil does, and the constructions row is unchanged without it. reduceArgumentCount stays for a call's argument count.
…t line to the limits
Brings in call as one instruction, .call over the typed MethodRef of its target with tail. and constrained. carried as prefixes, decoded from opcode 0x28. The lowered call and tailCall forms with their index and count operands, their step arm and their translator paths are deleted; the argument count is read from the MethodRef and the target from the link of the pc. Call and newobj share one link form. Every method states one named table that its literal, its evidence and its decoder take, and Method.ofRaw?, Method.ofBody? and decodedProgram? take it after the environment. Instruction.ofCallSite? decodes both opcodes from a call site operand, Instruction.statesLink marks the instructions whose link the code does not imply, and Method.withCode drops their links, so a rewritten body states its links again. ManagedCallsValid requires ascending keys bounded by the code, a direct link at every call pc tied to the site's method and token, and the construction check at every newobj pc; forged links of both kinds are rejected by the tests of both sides. Every call-family step rewrites its link fact in the pass that applies its step equation, and step_call_eq states the step as callStep of the link, a regular definition, so the kernel no longer evaluates the table read once per site. Against the head before the conversion the calls stepping row costs 801548 / 817861 / 822727 frontend heartbeats per instruction at 16 / 64 / 256 (821255 / 840326 / 846190 before) and 7131 / 5397 / 4963 kernel heartbeats (7742 / 5800 / 5315). The managed-call check costs 14906 / 13311 / 12913 heartbeats per site at 64 / 256 / 1024, up from 10585 / 9105 / 8734, for the added tie between the instruction's MethodRef and its site. Decoding a method costs 24775 / 24494 / 24425 per instruction (26581 / 26300 / 26230 before). 2,868 of 3,747 admitted corpus methods are defined from their decoder. The 35 conflicts with the newobj work were resolved to one form each: the newobj table and decoder argument order, one refusal function in the extractor, one method operand accessor, one linked-step macro and one version of the decoded-method test helpers.
3,747 of 13,291 methods of the extractor's own assembly are admitted and 2,868 are defined from their decoder, 273 more than before. The hole corpus skips 9,544 refused methods. The example Arithmetic::Calls now decodes through its two direct calls, so the canonical-methods test requires it to be defined from its decoder. The example that must keep a literal and report its first hole is Strings::SameText, which loads a string literal first.
An import test reads call targets through the shared helpers of Tests/GeneratedEvidence.cs since the call conversion, so a change to the helpers selects the imports suite as well. The selection test states that.
…elem Instruction gains ldlen, ldelem and stelem of a NumericKind, ldelem_ref and stelem_ref, and the value decoder decodes opcodes 142, 144-151, 154-159 and 162 to them, so the array check binds each emission with valueEncodingMatches. A handler table's ldlen and ldelem.i emit the same decoded instructions; only a typed ldelem (163) on a table still emits ManagedOp.tableElement. MemoryOp.arrayLength, referenceArrayLength, referenceArrayLoad and referenceArrayStore are removed, with the definitions that executed them. InstructionMemory.elementInstruction executes the new instructions from instruction, beside ldind and stind: value arrays, arrays of class references and managed handler tables, with arms of one opcode told apart by a stack constructor so allocation renaming selects the same arm. methodTableLength and methodTableElement move there from Execution. Consumer-visible changes: - step_memory_arrayLength_address_eq and step_memory_arrayLength_null_eq are now step_ldlen_address_eq and step_ldlen_null_eq; step_referenceArrayLength_eq, step_referenceArrayLoad_eq and step_referenceArrayStore_eq are step_ldlen_object_eq, step_ldelem_ref_i32_eq and step_stelem_ref_i32_eq. - step_ldelem_of_element, step_stelem_narrow_of_write and step_stelem_wide_of_write step the decoded integer accesses from element facts; step_arrayLoad_of_element and step_arrayStore_of_write remain for typed ldelem and stelem. - step_ldlen_table_eq and step_ldelem_i_table_eq step a managed handler table. - ldelem.i on an object that is neither null nor an array, or with a non-index operand on a null object, is invalidState; the null-table proofs state that divergence. - ldelem.i (151) on a table no longer compares a type operand with the table signature, since the opcode has none; the table's own signature types the loaded pointer, as for ldind.i. - The elements row of the stepping scaling test steps ldelem.i4 and stelem.i4.
The duration table still held times from before this branch: lookups at 150 s where it takes 2,040, assemblies at 303 where it takes 1,478, stepping at 300 where it takes 856. The packing put lookups, stepping and two more suites in one job that ran 55 minutes and started in the second round, so a full run spent 71 minutes in its suite jobs. The table now holds the times of the last full passing run, and the same 18 jobs and 303 job-minutes are estimated to finish in 40 minutes on the eight runners, with lookups alone as the longest. A job's limit was the largest named limit of its members, 30 minutes for most suites, which lookups alone would exceed. A job is now also given at least twice its measured time, rounded up to ten minutes, and the selection test requires that of every job, alone or packed.
Brings in call as one decoded instruction over its MethodRef, the link table passed to Method.ofRaw? and Method.ofBody?, and the call-family step dispatch on linked opcodes. Extractor/GenericEvidence.cs keeps both additions to DecodedOpcodes: the array length and element opcodes, and Code.Call beside the class field and construction opcodes under the comment naming direct calls. Tests/ValueDecoding.lean pins the union of both decodings, decoded 80 and undecoded 26 of 106 constructors: the five array constructors decoded, and call decoded with tailCall removed. Every other file merged without conflict.
The proof discharged the wide kinds with omega, which added Classical.choice to every proof that steps a narrow stelem, so the stepping scaling row's axiom guard failed. Deciding the width hypothesis false for those kinds keeps the axioms of step_arrayStore_of_write.
cil_runtime_models states, for each call a runtime model stands for, the model its operand names, checked by the kernel once, so a step reads it from one fact. reduceRuntimeModel reads a literal body's lookup without one.
The fixture stands for what a consumer can write with `import CIL`, and the documentation check requires that single import. The call conversion gave its forwarding method a placeholder method reference from the test support module. The method now states its call's method reference as a literal.
The call conversion removed the last use of the regular expression namespace from Tests/TailCallFixtures.cs and left a summary comment with no member under it. The suite runner fails a test build that has an unused import, so the dispatch suite stopped before running.
A typed ldelem or stelem in a generated outline now steps by
step_ldelem_any_of_element, step_stelem_any_of_write or the new
step_stelem_any_of_wide_write, citing the shape fact
cil_resolution_facts declares for its element type
(Extracted.method{n}_elementShape{k}). ProofOutline.ShapeFacts numbers
the element types in raw pc order as that command does, and an outline
refuses a typed access whose numbering it cannot reproduce.
The outline catalog gains ReadGeneric<UInt32> and ReadGeneric<UInt64>,
extracted with --type-argument; no earlier outline reached a typed
access. Tests/ResolutionFacts.lean steps a four- and an eight-byte
typed store from shape facts and checks that a four-byte shape cannot
step the eight-byte store.
Untyped array outlines change only in where the cil_checked_steps line
of an array read breaks (ArrayReadInt32, ArrayReadUInt64); the other
100 catalog outlines are byte-identical to what they were.
Cost of the correctness theorem of ReadGeneric<UInt32>, raw heartbeats
on this thread (Elab.async false):
arrayLoad_of_element 1,749,078
step_ldelem_any_of_element 1,753,154 (+0.23%)
ReadGeneric<UInt64>, step lemma 1,754,976
A specialized generic entry names its type arguments, so the generated
postcondition docstring of ReadGeneric<System.UInt32> ran past 100
columns and new-proof refused the method; the sentence now breaks before
its subject when it does not fit on one line.
The outline generator gains the shape accessors of a numeric array access and the closures of ProofOutline.ShapeFacts: the corpus has 13,417 methods, 3,764 admitted and 3,673 defined from their decoder. One more admitted method stops at ldstr, so 91 keep a literal.
memory_stepRenamed proves RuntimeModel.StepRenamed for the model of any MemoryOp, so a model table entry that resolves only memory operations adds its case to runtimeModel_stepRenamed by naming it. The model runs as memoryInstruction behind the unspecified-operand guard, and Memory.Renamed.memoryInstructionResult already relates that instruction's results on renamed memories. StepRenamed gains two premises, both required by memoryInstructionResult: - The source memory is well formed (source.WellFormed). The memory relation alone does not give the allocation and view invariants the memory instruction proofs read. - The source model step succeeds or throws (SuccessOrThrow of modelStep on the source). memoryInstructionResult relates results only for an observable source run; an invalid state or an unsupported operation has no renamed counterpart to state. Memory.Renamed.stepBoundary already holds both, as its formed and observable hypotheses, and passes them to the private stepCall. stepCall forwards them to runtimeModel_stepRenamed after rewriting the observable run by the call's link and model. The object constructor and intrinsic cases ignore the new premises. Nothing outside BoundaryStepRenaming.lean states StepRenamed or calls stepCall, so no consumer statement changes. Tests/RuntimeModels.lean instantiates the case for a whole-array view, a span copy and an out-operand division, and derives the case for any entry family that resolves only memory operations.
Program.closure read each visited method with program[index]?, so a
closure of n methods cost O(n * P) list steps in a program of P. The
search now takes a lookup: ClosureSearch.visit and run read through it,
closureWith is the only body of the search, and Program.closure is
closureWith (program[.]?) program.length root. Program.closure_eq_closureWith
rewrites a closure to closureWith over any lookup that agrees with the
list, so a proof decides it over an index stated once and pays
O(n * log P + e). No statement of closure_closed, closure_relocates or
closureEvidence_decodes changes.
program_index% (CIL/Extraction/FlowIndex.lean) writes FlowIndex.ofList
of a list as a literal tree whose leaves are the list's cell terms;
ModelTable reuses its list reader. Every extraction now states
programLength, programIndex and programIndex_get?, each checked once:
programIndex_eq is one cil_kernel_rfl against FlowIndex.ofList program,
which compares method{n} constants without unfolding them.
Tests/ProgramClosures decides its closure through the index.
Elaborating the whole Extracted.lean (raw heartbeats, Elab.async false):
| Extraction | Methods | Before | After |
| --- | --- | --- | --- |
| Arithmetic::Add | 1 | 12590029 | 12651370 (+0.49%) |
| VirtualCalls::DogLegs, largest example | 5 | 47892265 | 47983482 (+0.19%) |
| chain of 16 (generated Bodies) | 16 | 107812209 | 107980274 (+0.16%) |
| chain of 128 (generated Bodies) | 128 | 957295634 | 958228563 (+0.10%) |
The closure row of Tests/LookupScaling.cs decides each closure through
its stated index and reads n * log P + e units; it adds a long chain at
128/256/512, keeps the list form beside it, requires the four-method
tail to cost less through the index at every size, and measures stating
the index. Kernel heartbeats:
| Shape | Sizes | Through the index | Through the list |
| --- | --- | --- | --- |
| chain | 8/32/128 | 87394 / 335656 / 1422953 | 90395 / 437519 / 3533840 |
| long chain | 128/256/512 | 1422542 / 3013064 / 6568957 | - / - / 43269245 |
| fan | 32/128/512 | 140799 / 367218 / 1273057 | 144084 / 370459 / 1276182 |
| tail | 128/512/2048 | 55819 / 58512 / 61237 | 81699 / 179818 / 571795 |
Growth per unit between the last sizes and the first: chain 0.84, long
chain 1.02, fan 1.00, tail 1.01. Stating the index at 128/512/2048
costs 260137 / 857704 / 3248483 heartbeats (1.00 per method). The list
long chain at 512 was measured from a probe of the row's file.
A call of a BitOperations helper (IsPow2, PopCount, LeadingZeroCount, TrailingZeroCount, Log2, RoundUpToPowerOf2, RotateLeft, RotateRight), of the same helper an integer type declares, or of BinaryPrimitives.ReverseEndianness now keeps its call and runs the scalar intrinsic the runtime model table gives its method reference, in place of the lowered intrinsic, which no Lean check tied to its call. - CIL/Extraction/BitModels.lean adds one entry per owner and name: 8 under BitOperations, 61 on the ten integer types, and ReverseEndianness under the exact System.Memory scope. An entry's resolve gives a model only to a static, non-generic reference that takes one runtime integer type, then Int32 for a rotation, and returns the result its owner declares: Int32 for a BitOperations count, the type itself (a 64-bit word only at 64 bits) for a count the type declares, Boolean for IsPow2. Signed Log2 and signed 8- and 16-bit rotations have no entry. - modelEntries, runtimeModels_entries and runtimeModel_stepRenamed gain the entries; bitEntries_yields gives each model as an intrinsic. - BinaryTransfers reads spanMemoryScope; its private copy binaryScope of the same System.Memory literal is deleted. - Extractor/BitModels.cs holds the exact signatures and CallModel asks it first; the bit loops of BuildScalarOperations and ReverseEndianness() are removed from RuntimeModels.cs. Tests/BitModels.lean states each group's resolution, one kernel-checked test per result rule (BitOperations.PopCount gives an int word, UInt64.PopCount a long word, UInt32 and Byte counts an int word), the rejections (receiver, generic arity or method argument, wrong or mixed parameter, wrong result, signed Log2, signed narrow rotation, an undeclared helper, another owner, assembly or opcode), one mutation per group (LeadingZeroCount emitted at a PopCount site, UInt64.PopCount with an int word, ReverseEndianness(ulong) at 32 bits), each refused and each accepted by a table without the helpers, the same agreement under the scalar and AVX2 profiles, and steps against the lowered intrinsic: the counts and Log2 of zero, RoundUpToPowerOf2 of 0x80000001, and the byte reversal of a sign-extended short and sbyte. Tests/RuntimeModelInventory.txt is unchanged: 474 definitions. CallModel admits exactly the signatures Translate lowered, and signed Log2, signed 8- and 16-bit rotations and the Int128 and UInt128 BigMul forms were already absent from it. Call sites: the examples have 104 (BitOperations 32 in 30 methods, the integer types' own members 61 in 34, ReverseEndianness 11 in 11); the self-admission corpus has 2 (BitOperations.RotateRight(uint) and PopCount(ulong)). Example methods that decode in full under the scalar profile: 478 -> 552, none lost; methods kept as literals 713 -> 639. Corpus: 3,764 admitted and 3,673 decoded, unchanged. Rows, before and after: the lookups model lookup and agreement rows are unchanged (their tables are synthetic); in one file, deciding the runtime table's lookup of Math.Max costs 276,653 kernel heartbeats on the table without the helpers and 276,208 on the runtime table (8 -> 17 name groups, 49 -> 119 entries). Stepping, frontend / kernel heartbeats per instruction: calls 16/64/256 unchanged objectconstructors 16 185,725 / 4,517 -> 185,717 / 4,517 objectconstructors 256 103,425 / 2,075 -> 103,443 / 2,075 intrinsiccalls 14 248,249 / 6,492 -> 248,233 / 6,492 intrinsiccalls 62 161,284 / 3,281 -> 161,295 / 3,281
A call of PopCount, LeadingZeroCount, TrailingZeroCount or Log2 of BitOperations or of an integer type keeps its call since the bit helpers joined the runtime model table, so its operation is ModelCall(ScalarIntrinsic). Body.Pure and the scalar path walk matched only a bare ScalarIntrinsic, so an outline that reached such a count stopped there with a hole where it had stepped before. Body.Pure (ProofOutlineLoops.cs) and the result width of a pure word in the scalar path walk (ProofOutlineScalar.cs) now match the model call; cil_checked_steps already steps it with step_call_intrinsic. No extractor path emits a bare count intrinsic any more, so the bare pattern is replaced, not kept beside it. No outline matcher ever covered the other bit helpers (rotations, IsPow2, RoundUpToPowerOf2, ReverseEndianness), as a bare intrinsic or a model call; ReverseI16 and PowerU32 stay outlined with a hole, as before. Tests/ProofOutlines.cs adds Population64 (BitOperations.PopCount of a ulong) and PopulationU32 (UInt32.PopCount) and checks each outline steps its whole body. With the matchers reverted, the Population64 check fails. outlines-control passes: 41 outlines.
NarrowEvidence removes every generated theorem except the obligation under test, and matched a theorem name with \w+. An extraction now states programIndex_get?, whose name that pattern does not match, so a narrowed source kept it while removing programIndex_eq, which its proof cites, and the positive batch of the generic evidence check failed with an unknown identifier. The name pattern now accepts the ?, ! and ' a Lean identifier may carry.
A regex whose pattern is a constant is now a [GeneratedRegex] method. This converts the constant patterns among the inline regexes this branch added, and every constant pattern of the two evidence helpers Tests/GeneratedEvidence.cs and Tests/RejectedEvidence.cs: 31 call sites in ten files (GeneratedEvidence, RejectedEvidence, IncrementalEvidence, LookupScaling, ManagedDispatch, PreparedLeanFixtures, ReferenceAddOutlines, StrictBindingDecoding, SummaryCalls and scripts/TestSelectVerification). A pattern built at run time stays inline: one interpolated with a method number, a theorem name or a byte literal, one joined with Regex.Escape of a value, and the pattern parameters of ChangeByte, ChangeLiteralByte and TokenCost. The one-line theorem pattern of the kernel refutation check accepts the ?, ! and ' a Lean name may end in, as the narrowing pattern does. RejectedEvidence keeps its own import pattern because Tests/TranslationAudit.cs includes it without GeneratedEvidence. The inline regexes that predate this branch are unchanged in the other eight files.
MethodContract.Refuted, OutcomeContract.Refuted and OutcomeContract.RefutedCLR take the arguments of Holds and HoldsCLR and carry a counterexample: an input and memory meeting the precondition with a settled outcome the contract does not allow, or fuel exhaustion at every budget (Diverges). A run that reaches an unsupported operation, or one exhausted budget, is neither, although it can prove the negation of Holds. Each predicate has not_holds, of_fault, of_return and of_diverges; MethodContract.Refuted.of_fault replaces not_holds_of_fault, and invoke_unique moves to FuelLemmas beside Counterexample. Tests refute a never-exiting loop by divergence, show that a run exhausting one budget and a run reaching a hole do not diverge, and show that a hole's run proves the negation of Holds but no Refuted.
The theorem audit reports a refutation only for a theorem stating a contract's Refuted, matched by name and declaring module. A requested theorem stating Not of a contract's Holds is rejected, since a run the model does not cover, such as an unsupported fault, proves it; a lemma stating it is checked like any other, and a same-named predicate of another module is no refutation. A gate variant expected to be rejected now needs production's theorem to state a contract's Holds, and its refutation is compared at that contract's Refuted with the same arguments. The gate fixtures and the documented gate template state contracts. A rejected variant of a gate whose production states no contract fails at statement identity, and a negated refutation fails at the audit. The failure reporting test keeps a negated contract proved from an unbound string literal, which verified as a refutation before, and expects it refused. The refutations the contract suites verify, and the concrete ones in the Lean tests, now state Refuted through of_return or of_fault with the run that violates the contract. The dangling forwarder argument is refuted the same way: the run stops with a definite missing-allocation fault, so its rejection goes through of_fault. The stronger post refutation of the derived percent proof substitutes the returned value and states its bound. The helper lemmas that only served the negated forms, raises_unique and raises_not_returns, are removed from Tests/ContractConsequence.lean and Tests/ContractImports/DerivedPercentProof.lean. The joint replay and olean audit tests audit a real Refuted counterexample and approve propext and Quot.sound, which the library's refutation lemmas use. The joint replay refutation fixture declares its contract with one field per line, since a structure instance whose continuation line is not aligned with its first field does not parse. The definitional gate fixture imports the contract module.
Adds the structfields workload, which loads and pops the int64 field at byte 8 of the struct its byref argument addresses and then stores its int64 argument there on every cycle, plus structfieldscontract, which steps the same body under contract stepping. Both read the field address, the load and the write from supplied facts. The body uses the lowered field forms that extraction emits today, so these rows are the baseline for decoded struct field instructions. Heartbeats per instruction at 14, 62 and 254 instructions: structfields 263680, 156246, 131966 frontend and 6181, 3135, 2463 kernel; structfieldscontract 235129, 153886, 136336 frontend and 6161, 3113, 2441 kernel.
ldfld, stfld and ldflda of a struct field now step as the lowered access of the shape the layout environment gives the field: fieldLoad and fieldStore send a value shape to fieldAt or setFieldAt and an aggregate shape to aggregateFieldAt or setAggregateFieldAt, and the new fieldReference sends either to fieldAddress, keeping the class address fault. fieldAddressFault is removed and FieldShape.structOffset? names the offset ldflda adds. Extraction is unchanged and still emits the lowered forms, so the corpus counts do not move. The agreement theorems step_ldfld_value_eq, step_ldfld_aggregate_eq, step_stfld_value_eq, step_stfld_aggregate_eq and step_ldflda_struct_eq state each decoded step equal to its lowered one, and the field simprocs step a struct field by them from its shape fact. The contract, equivalence, renaming and embedding proofs cover the new arms through the general instruction lemmas, with fieldReference_contract, Memory.Equivalent.fieldReference and a Memory.Renamed.stepFieldAddress that now relates successful addresses. Tests/FieldShape.lean pins every receiver kind: a struct field of an object faults, a snapshot receiver yields its 16- and 32-byte vector fields and faults on a 4-byte one, a store through a readonly reference is unwritable and ldflda of a struct value faults. The structfields rows now step a decoded body. Heartbeats per instruction at 14, 62 and 254 instructions, before and after: structfields frontend 263680, 156246, 131966 to 265851, 158420, 134183 and kernel 6181, 3135, 2463 to 6276, 3233, 2561; structfieldscontract frontend 235129, 153886, 136336 to 237189, 156094, 138470 and kernel 6161, 3113, 2441 to 6259, 3215, 2543. One instruction in three is a field access, and reading its shape fact adds about 98 kernel heartbeats per instruction at every size, about 295 per access, which does not grow with the body. Frontend and total heartbeats rise 0.8 to 1.7 percent; kernel heartbeats alone rise 1.5 to 4.2 percent. The objects and memory rows move by 7 heartbeats or less.
Tests/FieldShape.lean now steps ldfld and ldflda of the nested struct field as aggregateFieldAt and fieldAddress of its offset, so every struct arm of the field simprocs is exercised. FieldShape.structOffset? ends in a wildcard arm. PROOFS-BINDING.md says how the field simprocs step a struct field and that cil.requireFieldShapeFacts covers every field step, and VALIDATION.md describes the struct fields rows.
CanonicalMethods.cs now also runs leancil blockers over every method leancil list prints for the examples assembly, under scalar, x64-v3 and arm64-advsimd at once, and compares the methods each defines from its decoder, as "<profile> <stable name>" lines, with Tests/canonical-examples.txt by the rules of canonical-methods.txt: a listed method that no longer decodes fails even with --update, and a newly decoded one fails until dotnet run --file Tests/CanonicalMethods.cs -- --update records it. One comparison function serves both lists. The runs only read the built extractor, and the check fails if its hash changes while they run. The six-method required list and its manifest are removed; these lines of the recorded list replace them: scalar System.UInt64 Examples.Arithmetic::Add(System.UInt64,System.UInt64) scalar System.UInt64 Examples.Arithmetic::Choose(System.Boolean,System.UInt64,System.UInt64) scalar System.UInt32 Examples.Loops::Countdown(System.UInt32) scalar System.UInt64 Examples.Arithmetic::Calls(System.UInt64) scalar System.UInt64 Examples.GenericMethods::Identity64(System.UInt64) scalar System.UInt64 Examples.GenericMethods::Repeated(System.UInt64) The SameText literal, Mutate and Fixture::Admitted checks stay. Changing the list selects the blockers suite. The recorded list has 1,657 lines: 552 methods under scalar, 553 under x64-v3 (ExceptionDocumentation::DivRem decodes only there) and 552 under arm64-advsimd, of 1,287 listed example methods.
The statement request of the proof gates names its Refuted flag where it named Negated, so the two accessor lines of the self-admission baseline and of the canonical method list change name. The corpus has 13,420 methods, 3,764 admitted, and the two renamed accessors stay defined from their decoder.
No regex in the ten test files of the earlier conversion, or in Tests/GenericEvidence.cs, Tests/InstructionIndexes.cs and Tests/NativeManagedDispatch.cs, is built at run time any more. A helper that looked for one method, theorem, link or file by writing its number or name into a pattern now matches every such line with a [GeneratedRegex] and selects the one whose captured number or name is equal: the decoded definition, raw definition, closed return type and links of a method, a one-line theorem by name, the diagnostics of one file, a component's lines, a signature by method name or type argument, and an obligation by name and proof form. The mutation patterns of the generic evidence check and the layout patterns of the managed dispatch check are generated regexes passed as values, with the byte literal prefix as a constant hole. The rendered-constructor scan matches every dotted name inside a string literal and looks it up in the constructor set. ReplaceExactly counts occurrences of its text by ordinal search. A pattern too long for one line is written with named constant parts in a raw interpolated string, not joined with +. The decoded definition pattern states the method number once and requires the same number in the names of its links, raw definition and type arguments.
Each of the 199 [GeneratedRegex] members of the extractor, the scripts and the tests is a static partial property (partial Regex Name { get; }) where it was a parameterless partial method, and its 266 uses read the property. The patterns and their options are unchanged. The extractor and all 208 entry programs under scripts and Tests build with the analyzer flags of the workflow.
…ured result FailureReports.Refuted searched the combined statement and marker text for a "LeanCIL refutes" line, and a raw statement printed a declaration name across lines, so a theorem that states no counterexample could supply the line and be reported as a refutation. The certificate now carries the audit's refutes field as refutation, the report is built from it alone, and the audit text no longer holds a marker. The certificate schema is 6, since a schema 5 certificate has no such field.
The audit read a missing or non-boolean expected.refuted as false, so a request for a refutation was compared with production's Holds and a theorem proving it matched. The audit now refuses such a request.
ldfld of a nested struct field through a reference read the field's
bytes with read, which faults .memory .uninitialized on padding. That
fault is definite, so ldfld followed by pop of a padded struct could
refute a contract. The lowered aggregateFieldAt now reads the field
through loadSnapshot when its bytes are uninitialized, as loadAggregate
does, after the null, bounds and lifetime checks, so those faults keep
their priority. aggregateFieldAt of a snapshot value pushes the slice's
snapshotValue, setAggregateFieldAt of a snapshot writes it with
writeSnapshot, and a 1-, 2-, 4- or 8-byte fieldAt of a snapshot reads
the number when the field's own bytes are initialized and is unsupported
otherwise. Decoded ldfld and stfld of a nested struct dispatch to these
forms and change with them.
Changed: step_aggregateFieldAt_reference_eq. Before, its right side was
do let address <- checkedAt ..; let bytes <- checkedAt (.address
address) size (read ..); return .next (pc + 1) (.scalar (.aggregate
bytes) :: rest) frame memory
After, the same with
if let .error .uninitialized := read memory address size
ordinaryAccessAlignment then
let copied <- loadSnapshot memory (.address address) (.aggregate size)
return .next (pc + 1) (.scalar copied :: rest) frame memory
before the read. step_aggregateFieldAt_home and
LocalSnapshots.load_aggregate_field keep their statements.
New: step_aggregateFieldAt_snapshot_eq,
step_setAggregateFieldAt_snapshot_eq, numericValue_snapshotSlice.
Tests: FieldShape padded_load_keeps_padding (ldfld then pop of a padded
Pair), padded_copy_keeps_padding (ldfld then stfld, and ldflda, ldfld
and stobj, keep the source's flags), padded_load_faults_first (bounds
and expiry first), snapshot_fields_load (distinct bytes, exact values,
an uninitialized vector byte; replaces snapshot_vector_fields_load) and
snapshot_uninitialized_word_unsupported (replaces
snapshot_word_field_faults); Semantics nested_uninitialized now succeeds
with a snapshot, nested_of_snapshot, nested_snapshot_store_size.
Heartbeats: shared tactic tests (8 modules, 776 rows) +0.02%, kernel
+0.10%; the 35 struct field examples unchanged.
Memory.Renamed.instructionResult cases over every arm of instruction,
and the arm of a nested struct field read through a reference now asks
whether read of the field's bytes is uninitialized before it copies
them. The proof rewrites that read of the target into the read of the
source with Memory.Renamed.read, as it already does for dereference in
loadAggregate, so the two sides take the same branch. The snapshot arms
of aggregateFieldAt and setAggregateFieldAt close through the existing
loadSnapshot and checkedWriteSnapshot steps. No statement changes.
The module is reached only through the renaming tests, which
lake build CIL does not build; the full build of the previous commit
failed here.
structField? compared typeStorage of the operand's held type with
declaredFieldStorage of the raw field, and both erase a vector's element
type, so an operand reading Lanes.narrow (declared Vector128<ulong>) as
Vector128<double> or Vector128<long> resolved to the field and loaded
its bits. The vector tags of FieldType now carry a VectorLane, the
integer element kinds a vector field may declare, and one decoder,
fieldKind?, gives the tag a held type is declared with: a primitive's or
an enum's kind, a checked struct's index, or an integer vector's width
and lane, the lane read from the element's name through primitiveField.
structField? and the raw-body site check instructionLayoutUses compare
fieldKind? of the held type with the declared tag. Generic layouts decode
the lane of a substituted vector field, and the extractor emits it.
Removed: declaredFieldStorage.
New: VectorLane, VectorLane.ofField?, fieldKind?,
Extraction.fieldKind?_aggregate.
Changed: LayoutEnvironment.structField?_eq. Before, its hypothesis was
(storage : typeStorage environment.rawLayouts held =
some (declaredFieldStorage declared.type))
After
(kind : fieldKind? environment.rawLayouts held = some declared.type)
The shape facts it proves, and the goals stepping a field shows, are
unchanged.
Tests: FieldShape refuses_another_lane (Vector128<double> and
Vector128<long> against the declared Vector128<ulong>) and
another_lane_load_unsupported (ldfld of the first faults unsupported);
VectorFields vector-lane, a same-width lane mutation of extracted
evidence that the field site check refuses.
Heartbeats: shared tactic tests (8 modules, 776 rows) unchanged; the 35
struct field examples +0.007%, kernel +0.008%.
The vector tags of FieldType carry the element lane since the previous
commit, and two test libraries that lake build CIL does not build still
wrote the bare tags: LayoutAccumulation.vectorProfiles and the layout
examples of Tests/VectorFields.lean. Their fields now declare
Vector256<ulong> or Vector128<ulong>, the lane the VectorFields site
examples already read through UInt64, and the structure instances they
touch are wrapped under 100 columns. No library code changes.
genericLayoutValid accepted a generic layout whose owner is a class (.objectConstructor), since genericOwnerIdentity spells a class and a struct owner alike, so computeLayouts admitted it; closeLayoutTypeWith then closed a class application found in the table to .aggregate, and a class instance field resolved as a struct field of that layout. genericLayoutValid now requires the owner to be a struct's generic definition (.constructor), which is the only owner the extractor emits, and closeLayoutTypeWith never looks up an application whose head is a class, so a class stays a class after substitution even against a table that was not checked. genericOwnerIdentity, which dispatch reads, is unchanged. No lemma statements change; genericLayoutValid and closeLayoutTypeWith keep their signatures. Tests: LayoutAccumulation classOwnerRejected (the class-owned Wrap1 layout is refused by layoutsValidIndexed and LayoutsValid while the struct-owned one is accepted) and classApplicationStaysClass (a class application against a table claiming it stays an application; the struct application still closes to its entry). Both failed before the change: the class-owned layout was accepted and the class application closed to the entry.
With no carried Field row, MetadataEnv.expectedField bound Item1 and Item2 of the platform ValueTuple`2 as the pair's first and second argument without reading the MemberRef's signature, so a reference declaring Item1 as int64, or as !1, bound as !0 and the operand passed holding the pair's first argument. The reference's own signature is the item's only declaration there, so expectedField now requires it to be !0 for Item1 and !1 for Item2, fails with operandMismatch otherwise, and returns the substituted declaration, which equals that argument. No lemma statements change. Tests: MetadataBinding refuses_a_pair_item_declared_otherwise (Item1 declared int64, and Item1 declared !1, each refused with operandMismatch); before the change both references passed. tupleWorld is now tupleWorldWith over the two item signatures, and reads_the_pair_from_its_own_reference is unchanged.
The certificate carries the structured refutation the audit read, so its schema is 6. The cli, core, imports and exports checks of verified.json expect schema 6, and the refused-certificate cases change the schema to 5, the one before it.
The certificate record carries the refutation the audit read, so the extractor's own assembly gains its two accessors. Self-admission admits 3,766 of 13,413 methods, both accessors are defined from their decoder, and no admission is lost.
For each of the eight arithmetic cases, a fault that surfaces as the promised CLR exception is no violation from any memory, so the contract is not refuted, and the same fault refutes a contract that promises the other exception. A build that maps overflow to divide-by-zero fails all three proofs.
The audit checks the decoded keys of a request before parsing it and refuses a key that repeats at any depth, naming it. A statement comparison takes exactly term and a boolean refuted; any other field is an error on that theorem. Scanning 65,536 distinct keys followed by a duplicate takes 91 ms including startup.
The duplicate-key scan stores each decoded key with its hash and compares the text only when hashes collide, so growing the key set never rehashes a stored key: with one 65,536-byte key followed by 8, 128 and 2,048 short keys the scan hashes 65,552, 65,938 and 74,666 bytes. The audit suite runs that byte count and a collision case, and requires a theorem error naming expected.term for a comparison that carries only refuted.
StatesContract indexes the audited nodes once and resolves each application in constant time: 2,000 and 32,000 applications take 0.266 and 4.690 ms where the walk took 19.421 and 906.405 ms, and a scaling check holds the growth under 32x. The statement mismatch diagnostics are built with raw strings; all 50 comparison cases return the same status, statement and error text as before.
The scaling check of StatesContract warms both inputs and compares the median time per walk over five batches of at least 20 ms: 0.130 and 1.821 ms at 2,000 and 32,000 applications (14.0x, limit 32x), where the walk before the index measured 3.624 and 895.788 ms (247.2x). The StatesContract docstring states the predicate it recognizes and its linear bound.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This draft works toward #568, #582, #596, #597 and #598. Decoded CIL as the sole executable representation remains the objective. On this head the extractor defines every method that decodes in full from its decoder (3,673 of 3,764 admitted methods of its own assembly); the lowered instruction language and the translator still exist for the rest.
The branch history was rewritten on 2026-11-16 to give every merge commit a subject and a description; no file content changed. Commit hashes in the entries below that predate that rewrite name commits of the old history, which CI runs still refer to by run number.
Implemented
Method.argumentAccesswith generated factsmethod{n}_argumentAccess{i}and thereduceArgumentAccesssimproc incil_step. The facts cost about 8,400 kernel-checked heartbeats per argument at 8, 32 and 128 parameters (10,800 with homes), and a lookups row fails a quadratic form.FeatureFlowValid.expandandFeatureListValid.knownprove the check accepts exactly the certificates the one-fact-per-local specification accepts.MethodTableandNativeMethodTablegain the fieldsentryCountandcounted, and a table load checks its index against the carried count. The step still costs time linear in the number of static bindings, and a load of entry i costs time linear in i.FieldRef(owner, index, type and metadata name), built byFieldRef.ofOperand?from a raw field operand; the class and static field instructions carry it. Templates write theirlinksexplicitly.ldarg.Instruction.argand its narrowing operand are deleted;ldargreads the declared signature and the parameter homes throughMethod.argumentAccess, andargumentAccess_of_evidenceproves that validated evidence reads an argument without a home at the narrowing of its storage. The 45 stepping rows are within 2% of their baseline.Instruction.ofRaw?decodes a raw opcode to the instruction ECMA-335 assigns it and refuses an operand its encoding cannot carry. 84 of the 109 instruction constructors decode from raw CIL; 25 do not yet.Tests/ValueDecoding.leandecides in the kernel a table of raw forms with the instruction each must give. Decoding costs 14,043, 14,015 and 14,007 heartbeats per instruction at 500, 2,000 and 8,000 instructions.indirectTarget, andstep_managed_call_eqstates the step with that selection as a rewrite target. The generated proofs ofcalliruns usecil_kernel_rfl, so the length of an owner identity no longer limits them; a run through a 400-byte owner is tested.ManagedCallsValidreads the link table by one walk beside the code and requires the link keys to ascend and to be call sites.ManagedCallsValid_iff_originalproves it accepts exactly what the list form accepts. Its cost per call site falls slightly from 64 to 1,024 sites, where a scan per site grew 3.23 times from 64 to 256.Tests/Objects.csverifies 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.MethodEvidenceValid,DeclaredValid, proved byrflin the generatedmethod{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.Safety.stepsit in its first match, so neither match exceeds the 79 alternativessplithandles. The 91 generated step equations state the same facts.step_raise_faultingcosts 7.1% more and has a raised heartbeat budget.Method.ofRaw?gives the method a raw definition denotes, with each instruction decoded byInstruction.ofRaw?and the frame, signature and homes computed by the functions the evidence checks use;Method.ofBody?takes the code and the init flag from the pinned body bytes aftercheckBody, anddecodedProgram?does so for every method of an extraction.Method.ofBody?_of_decodesrewrites it with the generated body check. Decoding a method costs 24,775, 24,494 and 24,425 kernel heartbeats per instruction at 500, 2,000 and 8,000 instructions.Examples/Proofs/DecodedAdd.leanprovescorrectness_decoded: the program thatdecodedProgram?reads from the bytes ofArithmetic::Addreturns the sum of its arguments modulo 2^64. The proof names neither the emitted method nor the emitted program, and changing theaddbyte tosubin 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.locallocis a CIL instruction:Instruction.stackAllocis deleted, the zeroing flag isDeclaredSignature.initLocals, whichDeclaredValidties to the localsinit bit of the body, andInstruction.ofRaw?decodes opcode 0xFE0F.MethodRef(owner, metadata name, signature, generic arity and method arguments); the declaring type, return type and parameter types are read from it.checkCallOperandrequires 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.ldind,stind,ldobj,stobj,cpblkandinitblkemit to the width, sign and alignment of the raw instruction. 39 forged emissions that every check accepted are rejected, and the 25 emissions the extractor produces are accepted.ldobjandstobjof an operand type the extractor refuses accept nothing but the span no-op.Instruction.unadmitted (opcode)replacesInstruction.unsupported: it carries the raw opcode and faults when stepped.Instruction.ofRawgives the instructionofRaw?admits and a hole otherwise (ofRaw_eq_unadmitted_iff),Method.ofRaw?maps it over the code and refuses code that names an undeclared argument, andMethod.ofRaw?_codestates that each pc holds the decoding of the raw instruction there. The extractor writes the raw opcode at every hole.Instruction.ofRaw?andInstruction.ofRawtake the raw instruction before the one they decode (none at the first pc), where a prefix stands, andInstruction.ofRawCodedecodes code in one pass that carries it;ldelemais the first instruction to read it. The checks that compare an emitted instruction with its decoding take the same previous instruction, andScalarFlowValid.instruction_checkedstates the match after it.fixedBytesliteral whose code joins numerals of at most 256 bytes withNat.lorandNat.shiftLeft. The kernel keys its caches by a hash that reads only the low 64 bits of a numeral (Hashable Natandexpr_eq_fnin the Lean source), so the separate numerals the extractor wrote before, joined by++, collided when they ended in the same eight bytes and made a body check quadratic in its numerals.fixedDigitsWithinis the one splitter, over digits of any width. The body check of 125, 500 and 1,000 string tokens now costs 88,900, 92,700 and 99,800 heartbeats per instruction (89,600, 136,300 and 201,500 before), and rows over 5, 10 and 20 KB of equal-tail and random numerals bound the growth at 1.15 per byte; the former form fails them at 10 KB. Whole body obligations of bodies of at most 256 bytes rise by 0.06 to 0.46 percent. Binding pages take the same form (fixedDigitsWithin 512over one joined code): the digest proof of a 4 KB page whose chunks end in the same eight bytes costs 23.26M heartbeats against 23.25M for random ends, 506.1M against 23.0M before. The splitter lives inCIL/Extraction/FixedDigits.lean, which imports only the prelude, so a generated audit module costs 1.92M heartbeats and 1.2 s where importing it through the Lean library cost 5.25M and 2.9 s; a check inTests/BodyLiteral.leanfails when that import closure reaches a Lean module.PrefixEntryFreestates over raw code that no branch or switch arm, reachable or not, enters the instruction afterunaligned.,volatile.,tail.,constrained.,no.orreadonly.. Body decoding already refuses such a branch, socheckBody_prefixEntryFree,instantiateMethod_prefixEntryFreeandMethodEvidenceValid.prefixEntryFreegive the rule for every method with body evidence and the evidence check decides nothing new;prefixEntryFreeWithdecides it in one pass over a bit mask of the branch destinations (about 1,380 heartbeats per instruction). The extractor refuses the same bodies inInstructionPrefixes.ValidateEntrywith the blocker "Branch enters the instruction after a prefix". No corpus, example or fixture method holds such a branch.starg, addressed withldargaand read withldarg; the lowered local forms for homes are gone, and the four raw forms decode.step_relabel_faultingis proved by splitting on the first match ofstepand costs 52,100 heartbeats where it cost 212,700.Method.fieldShapeandMethod.valueShaperesolve 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. No instruction reads them yet.ExceptionType, in instructions, faults, contracts and example proofs; text is produced for display only.stlocandldlocabefore a spanget_Lengthorget_Itemcall are emitted as themselves and checked against their raw instructions.StepMetadatarequires 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.CIL.Extraction.fixedBytesinstead 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.SliceMatchesjoins the assembly block, the rows and the#USentries of one slice against a prepared image,sliceBounddecides it, and its success implies the proposition under a bounded view. Deep verification reconfirms the metadata-rows fact throughBindingAudit.metadataRows, with each distinct Assembly block checked once, beside the body-bytes fact; a forged row page must fail exactly that fact (Tests/DeepVerify.cs). An unchanged deep result is reused, also under--proof-root: its key binds the compiled import closure, each certified closure part is hashed and its header read once per process, and a failure between staging a consumer deep result and publishing it leaves no receipt and no new entry.StrictBindingalso checks a type definition of a pinned image in constant work (TypeDefAt: name, kind, field range, base and nesting, at rows the claim states as hints), with absence of a NestedClass row shown by adjacent rows and the sortedness that rests on stated as a whole-table fact (TablesSorted); no deep request uses these yet. A run that opens the certified library from the local cache, a release or the closure cache traces that stage, so a forced full verification with a warm cache shows its library stage.Guards::CountandGuards::Indexclose again andTests/Guards.csruns in the evidence suite.Tests/HoleCorpus.cspins that no admitted corpus method (3,764) gets a parameter home from dead code or holds a dead prefix other thanunaligned..cil_decoded_method method{n} := Method.ofRaw? ..., and the kernel computes the definition from the raw body. A method decodes in full when no pc holds a hole and every pc is reachable; every other method keeps its literal definition. 3,673 of the 3,764 admitted methods of the extractor's own assembly are defined this way (Tests/canonical-methods.txt), as are the examples Add, Choose, Countdown and Calls. The blockers report gives the first refusal of each of the 91 that are not:callvirt34, fields 23 (9 more since the deep binding scripts, whose records hold a 32-byte digest struct),ldstr19, a call or construction the extractor still translates 15 (an exception constructor followed bythrow13, other modelled runtime calls 2).ldindandstindare the instructionsldindandstindover a numeric kind;load64,store64andtableLoadare deleted.ldnull,castclassandisinstare instructions with decode arms;objectTestand the memory operationnullObjectare deleted.Method.ofRaw?decodes the instantiated code.ldfld,ldfldaandstfldover aFieldRef, stepped throughMethod.fieldShapeand decoded from opcodes 123 to 125. The six class field memory operations, their site and match checks and their translator arms are deleted. A class field store is admitted only of the field's stack kind. The extractor reads a field name from the bytes of its metadata row. The same three instructions over a struct field step as the lowered access of the field's shape (step_ldfld_value_eqand four more agreement theorems); the extractor still emits the lowered forms for struct fields. Stepping a decoded struct field body costs 0.8 to 1.7 percent more heartbeats per instruction than the lowered one, and 1.5 to 4.2 percent more kernel heartbeats (about 295 per field access, constant in the body length).ldsfld,ldsflda,stsfldand fieldldtokenover aFieldRef; the static memory operations are deleted, the static field tie compares the field name, and the stepper builds a static read from the body's site fact. These four instructions have no decode arm yet.newarrcarries its raw type token and steps through the element shape the layout environment gives it;newArrayandnewReferenceArrayare deleted, and aSystem.Objectelement array is refused by identity.steptake their target from the link of their pc and fault withunlinkedCallwithout one, andcil_instruction_equationsstates a link fact per call site.steprun through named functions (intrinsicCall,featureCalland the rest).RuntimeModelsAgree, a new part ofMethodEvidenceValid, ties each call to a modelled runtime method to its entry in a typed model table.memory_stepRenamedtransports the model of every memory operation under an allocation renaming, so an entry family that resolves only memory operations adds its case toruntimeModel_stepRenamedby naming it;RuntimeModel.StepRenamednow takes the well-formedness of the source memory and an observable source step. A call of aBitOperationshelper, of the same helper an integer type declares, or ofBinaryPrimitives.ReverseEndiannesskeeps its call and runs the scalar intrinsic that its entry inCIL/Extraction/BitModels.leangives its method reference (70 entries; signedLog2and signed 8- and 16-bit rotations have none); a proof outline steps the four bit counts through that call.ExecutionFault.definiteis false for an unsupported instruction and for fuel exhaustion,Settledrequires a definite fault, and the refutation lemmas takeSettled. A refutation is a counterexample:MethodContract.Refuted,OutcomeContract.RefutedandOutcomeContract.RefutedCLRcarry an input and memory that meet the precondition with a settled outcome the contract does not allow, or exhaustion at every budget (Diverges). The theorem audit and the gate runner accept a refutation only as one of these, matched by name and declaring module; a theorem statingNotof a contract'sHolds, which a run that reaches a hole can prove, is refused (Tests/FailureReporting.cskeeps the forged proof that verified before).newobjis one instruction over the typedMethodRefof its constructor, decoded from opcode 0x73;newAggregateandnewObject, their translator records and their step lemmas are deleted. Each method states one named link table,method{n}Links, which its literal, its evidence and its decoder all take, so the links of a decoded method are the ones the extractor wrote.ManagedCallsValidties every livenewobjto its raw site: the site names the instruction's constructor, the linked method is the one the site names, a class gets an object link and a value type an aggregate link, and the bases and the size match the constructor's raw method. Negative tests reject a forged link index, kind, base list and size, a missing link, a call opcode and a constructor owner the site does not name. Constructors of span and exception types keep their literal models.callis one instruction over the typedMethodRefof its target, withtail.andconstrained.carried asCallPrefixes, decoded from opcode 0x28; the loweredcallandtailCallforms with their index and count operands are deleted, the argument count is read from theMethodRefand the target from the link of the pc.Instruction.ofCallSite?decodescallandnewobjfrom a call site operand,Method.ofRaw?,Method.ofBody?anddecodedProgram?take the link table after the environment, andMethod.withCodedrops the links of both, so a rewritten body states its links again.ManagedCallsValidrequires a direct link at every call pc, tied to the site's method and token. The decoder admits a call that the extractor translates to a plain static call; every other kind of call is still translated.Mathhelpers (Min,Max,Clamp,Abs,Sign; 31 call sites in the corpus and 44 in the examples), andVector128.CreateScalarUnsafeandGetElementoverVector128andVector256ofulong(23 sites in the examples). A modelled call leaves the unspecified-operand guard to its model, which states the operands it observes; a linked managed call keeps its guard, andstep_call_linkedstates that its step is unchanged.reduceRuntimeModelevaluates the model of a closed method under a variable environment, and the stepper rewrites a modelled call whose intrinsic step the kernel cannot evaluate withstep_call_intrinsic. The intrinsic call stepping row costs 32% fewer frontend and 71% fewer kernel heartbeats; rows for instance and virtual calls record today's cost, about 61,000 heartbeats per virtual table entry.step_call_eqstates a call step ascallStepof 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).newobjstep 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/GeneratedEvidence.cs, which forge a decoded method through its decoder call or through the raw definition the decoder reads and fail on a method kept as a literal. Every rejection test is kept: a forged decoder is refused byDeclaredValid,MethodShapeValidorManagedCallsValid, and a changed raw instruction byScalarFlowValid.ldlen,ldelemandstelemby numeric kind, the reference load and store, the typedldelemandstelemover their element type, andnewarr. The loweredarrayLoad,arrayStoreandarrayTransfermemory operations and the managed table length and element operations are deleted with their translator records. A typed access resolves its element shape from the layout environment, which binds the width its step uses, and a by-ref-like element is refused there. An object type binds only to a pinned class or toSystem.String, so an array of an interface orSystem.Objectelement is refused in Lean and no longer only by the extractor. Stepping an element load or store by kind costs what the lowered forms cost (278,864 against 278,242 frontend heartbeats per instruction at 10 instructions). A typed access costs 6 to 8 percent fewer frontend heartbeats than the lowered forms (256,343, 148,602 and 116,353 per instruction at 16, 58 and 254 instructions), stepped from facts derived from the element shape factscil_resolution_factsgenerates (step_ldelem_any_of_element,step_stelem_any_of_writeand the transfer forms).ldelemais the instruction.ldelema element readOnly, decoded from opcode 143 with the flag set when the instruction before it isreadonly.;readonly.decodes to.nop, and any other instruction after it, orldelemaafter another prefix, does not decode. Its step reads the element shape the method's layouts give the operand type and forms the address with the unchangedarrayAddress.MemoryOp.arrayAddress, the loweredArrayAddressoperation,Arrays.ValidateReadOnlyand the readonly window of the scalar check are deleted: a site afterreadonly.must be anldelemaemitting its decoding, and a branch into it is refused byPrefixEntryFree.step_arrayAddress_of_elementgives way toarrayAddress_of_elementandstep_ldelema_of_element. The address stepping rows cost 4 to 8 percent less than the lowered form. Areadonly.site requires the instruction after it to beldelema, which with fall-through andPrefixEntryFreeis the rule that onlyldelemafollowsreadonly.. Per site at 512 sites everyScalarFlowValidrow is at or below its cost before the conversion (plain addresses 277,254 against 277,621, readonly addresses 364,641 against 396,905, block copies 471,028 against 472,062). The generated bodies of those rows carry the byte offsets extraction writes, which about doubled them. No corpus method holdsldelema; 61 methods of the examples do.DecodedSummarybinds a checked method contract to a method defined from its decoder: the contract, the proof that it holds, and the method's evidence record by pin, token and type arguments.decodedProgram?_eq_sometransfers it to the program read from the body bytes, and the site lemma gives a caller the token and type arguments of the callee it links. Examples prove one caller property both by stepping through the callee and through its summary: the generic identity at one and two sites,Arithmetic::Calls, and callers with 1, 4 and 16 calls of a method that writes through a reference. At 16 calls the summary proof costs 52.1M heartbeats with the summary's own proof, binding and decoding included, against 158.4M stepped, and 621,945 kernel heartbeats against 3,228,438.Tests/SummaryCalls.csfails when the cost per call through a summary grows by more than 1.6 times from 4 to 16 calls or when the summary proof at 16 calls costs as much as stepping. Negative tests refuse a contract whose footprint omits the written cell, a caller that leaves the callee's precondition unproved, a callee whose raw definition is forged, and a summary bound to another method's token.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 whichldfldof 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.Item1andItem2of the core-libraryValueTuplepair keep indices 0 and 1. All 5,065 instance field accesses in the admitted corpus have owners in the module itself.System.Objector as a generic class is admitted in Lean as the extractor admits it: a class-like generic instance is an application over a head that states it is a class, and binding compares the head with the kind the metadata gives. The 45 corpus methods (88 admitted entries) that Lean refused are accepted. The arity of a generic owner is tied to its GenericParam rows: an owner without parameters carries the adjacent rows that bracket it, so a type definition with parameters named without arguments is refused in Lean and no longer only by the extractor. That rests on the table being sorted by owner, as ECMA-335 requires, which no check reconfirms yet. A method whose signature has no GENERIC flag is read as having none without brackets, as before. Over 60 corpus extractions the brackets cost 1.7 percent of total heartbeats (the tables check 16 percent, the body check 2.3 percent).Tests/SelfAdmission.csgains an opt-in mode that checks every admitted entry in Lean (about 2.7 CPU-hours; no suite runs it); on290e747fLean accepts all 3,760 admitted corpus methods.method{n}_calls_validatedtheorem is decided in the kernel onManagedCallsValid, 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).MethodEvidenceValiddoes. 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_methodwrites an all-zero struct local asList.replicate size 0, the term a literal definition has, so a caller's goal after frame entry is unchanged by decoding.System.Objectconstructor is the first entry of the runtime-model table. The base constructor call of a constructor stays one.callwith no link, where the extractor lowered it topop. A call whose method the table models states no link and a call it does not model states the link the call check required before;ManagedCallsValidtakes the modelled set and decides both in its one match on the instruction, so a pc that is not a call pays about 79 heartbeats for it.callEmitsNoPop, part ofUnsafeCallsValid, refusespopat a call or construction site, and the runtime catalog lowers nothing. Stepping a constructor's base call costs 18 to 25 percent fewer frontend heartbeats than thepopdid at 16, 64 and 256 instructions, and the calls stepping rows 5 to 9 percent fewer kernel heartbeats. Model facts are proved per table entry, so a further entry adds a case. This conversion defines 791 more corpus methods from their decoder.ldsfld,ldsflda,stsfldand fieldldtoken. Before, a forged extraction could put one field's descriptor at a site whose token names another, and a static load returned the other field's value. A static whose owner is not carried is refused, except the platform constant the feature check requires verbatim, and a static named through an instantiated owner is refused.StaticIdentitiesValid, a new conjunct ofTranslationValid, requires one static identity per field and one field per identity in the whole program, by sorting the pairs in both directions (oneToOne_spec); before, two fields could share an identity and alias in the model. It costs 22,544, 20,876 and 22,706 heartbeats per site at 8, 32 and 128 sites. The extractor reports an instance field operand whose owner is not carried as a blocker with its reason.Program.closurecomputes the methods a method reaches through its links and checks every entry it relies on;MethodContract.Holds.restrictcarries a contract proved in a program to the closure, andDecodedSummary.relocateinto any program the closure relocates into. Theclosuressuite proves a contract once, binds it over its closure and applies it in three programs, and Lean refutes a relocation into a target with other bytes. The search takes a lookup (closureWith), andProgram.closure_eq_closureWithrewrites a closure to one over any lookup that agrees with the list. Every extraction statesprogramLength,programIndex(a balanced tree written byprogram_index%) andprogramIndex_get?, checked once by one kernel comparison, so a proof decides a closure of n methods with e link callees in a program of P in n log P + e steps: a whole-program chain costs 87,394, 335,656 and 1,422,953 kernel heartbeats at 8, 32 and 128 methods (90,395, 437,519 and 3,533,840 through the list), and a four-method closure 55,819, 58,512 and 61,237 in programs of 128, 512 and 2,048 (81,699, 179,818 and 571,795 through the list). Stating the index adds 0.49% to the elaboration of theAddextraction and 0.10% to a 128-method one.DivisionIntrinsics.UnsafeLowNextreturnsUnsafeLow(x) + 1, andExamples/Proofs/VectorSummary.leanproves it once by stepping throughUnsafeLowand its two modelled vector calls and once from aDecodedSummaryofUnsafeLow. 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.mainhas no proof of a caller ofUnsafeLowto compare with. A forgedUnsafeLowthat reads the other lane is refused by the body check.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.x64-sse2profile is removed.StrictBinding:methodMetadataBoundandMetadataRowsBoundbound the carried rows of a method across pages.Classical.choice; that check costs 57% less on Add and 44% less on Countdown.CIL.stepitself 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.stepreaches the widening only through it, andTests/MixedNativeOpcodes.leanproves 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.addon a reference and an integer keeps the checked byte-offset semantics of the form it replaces, andTests/ReferenceTests.leanproves the two equal and rejects the old lowering.addon a native method table and an integer offset, in either order, executes the checked cursor addition;ManagedOp.tableOffsetand the C#TableOffsetrecord are deleted.verify --deep-checksexposes them, and replay failures are attributed to the declaration that the kernel rejected.StrictBindinggains the check that a carried Assembly block (table header bytes, decoded header, Assembly row, and the assembly's string and blob entries) equals the pinned image's bytes, withassemblyMatches_of_assemblyBoundproving the proposition from the check. Heap keys are compared through a numbering the check derives; a row key without its entry and an entry no row names are refused. The same check covers the carried table rows of a slice with the#Stringsand#Blobentries they name (RowsMatch,rowsBound,rowsMatch_of_rowsBound): a MethodDef row is compared with its body address column masked, and one sort and merge-join builds the numbering, at 1.07 times the cost per added row from 256 to 1,024 rows. The extractor's own slices for 88 methods and 949 rows across all eleven carried tables are accepted. The metadata root accepts a 256-byte version field.Validmask, 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.core,evidenceorintrinsics, andTests/Strings.cs,Tests/Identities.csandTests/StrictBindingFixture.csrun in a suite.- Build with .NET 11. Share hash operations and reduce repeated work in stepping, embedding, metadata lookup, extraction and audit preparation.Proof-author changes
and,or,xor,not,shr_un,conv_i1toconv_u,ceq,cgt,cgt_un,clt,clt_un,br,brfalse,brtrue,bne_un,bge_un,bgt_un,ble_un,blt_un,ldc_i4,ldc_i8(argumentvalue),ldloc,stlocandldloca. Lemmas named after an instruction follow.divide,checkedArithmeticandcheckedConvertare replaced bydiv,div_un,rem,rem_un,add_ovftomul_ovf_un, andconv_ovfandconv_ovf_unoverConvTarget;conv_iis its own instruction.step_checked_result,step_conv_ovf_resultandstep_conv_ovf_un_resultreplace the earlier result lemmas, andguard_divtoguard_mul_ovf_unare incil_guard.ldlocandstloctake only an index; narrowing comes from the slot kind.step_local_annotationandstep_setLocal_annotationare removed.ldlocaon a span local pushes the view it holds.retreads its narrowing from the declared return type (Method.returnNarrow,declaredNarrowinCIL/Resolution.lean).addon a reference and an integer, in either order, executes the checked byte offset;step_add_reference_i32_eq,step_add_reference_i64_eqand the read-only and commuted forms state it.addon a native method table and a 32-bit or native offset, in either order, executes the checked cursor addition; it returnedinvalidStatebefore.step_add_table_i32_eq,step_add_table_i64_eqandstep_add_table_commuted_eqstate it, andManagedOp.tableOffsetis removed. Extraction accepts the table form only for opcodeaddwith no operand.CIL.stepbegins with the two table arms, so asplitonstepleaves 14 exclusion hypotheses in its last case; it left 12.step_add_commuted_eq,step_add_readOnly_commuted_eq,step_memory_add_commuted_eqandstep_memory_add_readOnly_commuted_eqare closed withid rfl.Memory.Renamed.stepReferencenow depends onClassical.choice.checkedNative_bindis public inFixedStepHelpers.FeatureStateisFeatureFactsover a list of index and word pairs, and the entry state haslocals := [];featureSuccessorstakes the stack;FeatureFlowValid_iff_listis replaced byFeatureListValid,FeatureFlowValid.expandandFeatureListValid.known;checkFeatureSiteis removed;factWeakensandfactsWeakenare inFeatureLocals.lean. A handwritten feature certificate lists only known facts.CIL.Extraction.linkKeysAscendandlinkKeysAscend_boundarekeysAscendandkeysAscend_boundover any element type.CIL.CodeSuffix.advanceandlookuptake an implicit element type; generated suffix and instruction facts keep their statements.cil_resolution_factsalso declares{m}_argumentAccess{i},{m}_parameterSuffix{16k}and, with homes,{m}_homeSuffix{16k},{m}_homesAscendand{m}_localCount, and it fails on homes that do not ascend or on a signature it cannot resolve.CIL.stepmatches on the instruction andCIL.widenMixedapplied to the stack.fallback_relabel,fallback_raise,fallback_appendLocalsandMemory.Renamed.stepFallbackstatevalueswhere they statedCIL.widenMixed op values. TheCIL.step.eq_Nlemmas of the arms that match the stack take the hypothesiswidenMixed op stack = pattern, sosimp only [CIL.step]needsCIL.widenMixedandCIL.nativePureBinaryin its simp set; the generatedstep_*_eqequations keep their statements.base_relabel_binaryandbase_relabel_comparisontake the instruction first;nativePureBinary_relabelandwidenMixed_relabelare removed.CIL.stepgives no meaning to local instructions and has noframeparameter;step_feature,step_return,step_intrinsic,step_profile_eq,BaseRelabel,Fallthrough,Branchingand the fallback lemmas lose that argument.vectorArg,vectorArgAddr,vectorLocal,vectorLocalAddr,setVectorLocal,lane,laneAddress,setLane,newVector256,asRef,tableAddress,skipInit,init256,bitcast256,mul64,byteToBool,Method.vectorLocals,Method.vectorArgs,Frame.argumentsandAddress.home.Framehas four fields.TranslationValid,MethodEvidenceValidandMethodsCheckedtake the pin list. Handwritten certificates must supply the metadata evidence.broadcastBinaryMethod,broadcastShiftMethodand theinvoke_broadcast*facts take the declared signature and environment.id rfl, sosimpapplies them as propositional lemmas; statements are unchanged.verify --format jsonreport is schema 2.verify --deep-checks digests.sha256runs the deep checks; there is no separate audit command. A defaultverifyprintsBinding: defaultand one line per trusted fact.StrictBinding, body proofs compose throughcheckAll,ClaimsHoldandPagesHold;ClaimedBodiesBound,ClaimPagesBoundandclaimedBodiesBound_of_pagesare removed.#-..arg iis written.ldarg i; its narrowing comes from the declared signature, not from an operand. A closedcallirun is proved bycil_kernel_rfl, and a singlecallistep bystep_managed_call_eqwith a kernel-checkedindirectTargetfact.validateManagedCallWithtakes the link read at the site. A mutated declared signature is rejected bymethod{n}_declared_validated, no longer bymethod{n}_shape_validated, andargumentAccess_of_evidencetakesDeclaredValid..stackAlloc zeroedis written.localloc, with the flag indeclared.initLocals;DeclaredSignaturehas the fieldinitLocalsandStepMetadatathe fielddeclared. ACallSiteliteral statesmethod := { owner, name, hasThis, genericArity, returnType, parameters };declaringType,hasThis,returnTypeandparameterTypesare accessors.step_relabel_faultinghas a raised heartbeat budget..unsupported descriptionis written.unadmitted opcode. An exception is a typed value (.throw .overflow,.thrown .argumentOutOfRange); proofs that named exception text name the member.StepMetadatahas the fieldenvironment;segmentStores,untouchedLocalsandSegmentLocalEffectstake the body; a homed argument appears as.starg,.ldargaand.ldarg. Generated byte definitions readCIL.Extraction.fixedBytes n 0x....load64and.store64are written.ldind .i8and.stind .i8; a narrow or native indirect access names its kind the same way..memory .nullObjectis written.ldnull, and.objectTestis written.castclass typeor.isinst type..ldfld field,.stfld fieldor.ldflda fieldwith a namedFieldRef;step_ldfld_eq,step_stfld_eq,step_ldflda_eqand their word, reference and array forms replace the class field forms ofstep_memory_eq.argumentStepisequationStep..ldsfld field,.ldsflda field,.stsfld fieldor.ldtoken;step_ldsfld_eq,step_ldsflda_eqandstep_ldtoken_eqstate their result as a match on the read, andstaticAtisMethod.staticAt.step_newarr_i32_eqandstep_newarr_i64_eqreplace thestep_newReferenceArrayequations; after steppingnewarra goal showsallocateElementsof the element shape.managedSteptakes the link of its pc, and an extraction statesmethod{n}_link{pc}facts.run_monoandinvoke_monotakeStable. A refutation from an unsupported fault no longer elaborates. A refutation is stated ascontract.Refuted program method(orRefutedCLR) and proved byof_return,of_faultorof_diverges;not_holds_of_faultisMethodContract.Refuted.of_fault, and a rejected gate variant needs a production theorem that states a contract'sHolds.steprewrites withstep_intrinsic_eq.cil_decoded_methodgets its step equations fromcil_instruction_equations; the command takes the field references the method names..newobj constructorwith aMethodRef;step_newobj_eqstates its step as a match on the link of its pc, and after the link fact rewrites the goal shows the earlier do-block withconstructor.parameters.lengthwhere the literal argument count was.step_newAggregate, its action form andrun_newAggregate_of_contractarestep_newobj_aggregate,step_newobj_aggregate_actionandrun_newobj_aggregate_of_contract, and the first and last take an aggregate link premise.objectSiteType,StepEffect,StepContractandSiteConsistenttake a pc;step_calleeconcludesreadsLink. An extraction writesmethod{n}Links,methodEvidence.linksandmethod{n}_links, and its decoder call takes the table..call method prefixeswith aMethodRef;.tailCallis.call method { tail := true }.step_call_eqstates the step ascallStepof the link at the pc.Forwards,ForwardsOutandWP.load_call_storetake the call'sMethodRefand its arity, andMethodIdentityandStructuralLabelsstate call facts over theMethodRef. A body built withMethod.withCodehas no link at a call ornewobjpc until its links are stated.validateLinkedCallWithchecks both instructions;callOf?,construction?,ManagedCallsValid.reads,ManagedCallsValid_of_implied,all3_impliedandManagedCallsValid.linkAt_eqare removed. A suppliedbody.linkAt pc = linkfact rewrites with the step equation..ldelem kind,.stelem kind,.ldelem_ref,.stelem_ref,.ldelem_any elementor.stelem_any element, and a length read.ldlen.step_arrayLoad_of_element,step_arrayStore_of_writeandstep_arrayStore_i64_of_writearearrayLoad_of_element,arrayStore_of_writeandarrayStore_i64_of_write.ldelem.ion a null table with a scalar that is not an index givesinvalidStatewhere it threw a null reference.Instruction.typeTest?isofType?, andMemory.Renamed.managedSteplost an unused argument.cil_contract_stepsskips a local invocation fact whose start memory is a different variable from the memory the call steps from; kernel heartbeats on the shared tactic libraries are unchanged. In a proof with several summarised calls, clear the earlier frame once the next call's frame exists.LocalSnapshots.read_word64reads a remembered 64-bit local.cil_checked_stepssteps a call without a link on in the same method. With the link fact and the model fact the stepper rewrites a modelled call bystep_call_model, and a directly linked.callbystep_call_direct;step_call_eqremains for a call whose link no fact decides.callSteptakes an argument for the unlinked case, and thecil_managed_callsmacro is removed.TranslationValidhas the conjunctStaticIdentitiesValidandtranslation_of_methodsa parameter for it;BodyEvidencehas the fieldstatics; a linked static collision is the typedStaticCollision;MetadataIndex.linkisIndexTables.link. The metadata errorsunboundInstanceField,unboundStaticFieldandinstantiatedStaticFieldare new.SegmentState.localFootprinttakes the body. Thex64-sse2profile no longer exists;x64-sse42is the lowest x64 profile.Fixes for failed CI runs
Defects in the library or tools that a run exposed:
rfland reached the recursion limit;declaredNarrowanswersnonefor any head other than a primitive or an enum, anddeclaredNarrow_eq_storageproves the value unchanged.stindfact that never applied and, for a one-byte write, accepted a derived fact the kernel rejects; each derived fact is now type-checked.clisuite rebuiltExtractor/binwith the pack's version stamped in, so later suites in the same job ran another extractor than the job was given (the check is onmain; the suites first shared a job on this branch). The pack builds into its own directories and the test fails when the shared extractor's hash changes.Tests and CI configuration:
evidenceexceeded its 30-minute limit after seven test libraries were registered in it; the duration table CI packs jobs from now holds measured times, and a job is given at least twice its measured time.[GeneratedRegex]is a static partial property (199 of them), and the thirteen test files this branch reworked build no pattern at run time.df75c870; a full run takes 60 to 66 minutes. Thelookupssuite reads each control and each open form in the file of its decided statement, 69 fewer Lean runs, with every row within 0.4 percent.Measurements
Extracted.leancosts 2 to 2.3 times what it costs on main (Add: 4.8M to 11.3M heartbeats). Of the 6.5M added for Add, 4.6M elaborate the literal metadata, name and table bytes and 2.0M run the checks; the checks of the lowered program, 2.4M to 16.4M per file, are still carried beside the decoded evidence.cil_decoded_methodverifies the proofs of Add, Choose and Countdown unchanged, with the same heartbeats, kernel heartbeats and axioms for the correctness theorems. Defining the method costs about 45,000 heartbeats per instruction, 4.1 to 4.3 times the emitted literal with its facts, and adds 6.0 to 6.6% to an extraction module (measured before the field instructions decoded); that is a regression against the 5% threshold, caused by running the decoder once to compute the literal and once in the kernel.main; sub-method regions and an invalidating reuse store are missing. Use canonical decoded CIL as the sole executable instruction representation #568, Emit canonical CIL and metadata without constructing specialised executable instructions #582 and Migrate checked execution and consumer proofs from CIL.Op to canonical CIL #598 wait on the same conversion: 84 of 109 instruction constructors decode, 552 of 1,191 distinct example methods decode in full, and the lowered language, the translator and the raw-against-emitted checks are all still present.main(27953edb, built once; its rows match CI run 43422873269). Heartbeats, with kernel heartbeats in brackets; a summary row includes the summary's own proof, its decoding and its binding.CountCalls:main10,373,560 (655,554), stepped here 9,807,269 (453,183), through a summary ofDecrement9,949,785 (240,803).Identity64:main1,543,005 (64,260), stepped 1,556,811 (57,833), summary 2,051,844 (87,160).Repeated:main2,398,448 (68,830), stepped 2,424,688 (63,273), summary 2,478,344 (103,540).Nested:main2,414,643 (80,782), stepped 2,440,469 (73,854).Callsfor every input, whichmaindoes not prove: stepped 8,361,015 (347,408), summary 9,292,411 (237,414). A single use of a summary costs more frontend heartbeats than stepping in every example and less kernel work only forCallsandCountCalls; reuse is where it pays, 52.1M against 158.4M at 16 calls of one callee. Proof objects and module sizes:CountCalls20,489 objects onmain, 18,145 stepped and 11,072 through the summary, in a module of 664,616 bytes onmainand 897,144 here;Identity642,193, 2,399 and 3,612 objects.Callsbyrflat one input, costs 1,882,199 heartbeats and 524,220 kernel heartbeats on this head against 1,412,152 and 374,759 onmain: 33% and 40% more for evaluating a decoded method with two calls.Instruction.ofRaw?decodes 84 of 109 instruction constructors, and every other opcode decodes to a hole. The translator files (InstructionTranslation.cs,Operation.cs,TypeTests.cs,Throws.cs,FrameMetadata.cs,ParameterStorage.cs) total 1,532 lines, against 1,327 before the conversions of this PR;Operation.csalso holds the typed operand records, and the count has not been split between those and the lowered forms. 3,673 of 3,764 admitted corpus methods are defined from their decoder. The acceptance coverage above was not rebuilt on this head.Remaining work
callvirt, 23 at fields, 19 atldstr, 13 at an exception constructor followed bythrowand 2 at other modelled runtime calls. That corpus is the extractor's own assembly, which is mostly simple code. In the examples assembly 552 distinct methods decode in full under the scalar profile (553 underx64-v3, 552 underarm64-advsimd;Tests/canonical-examples.txtrecords each and the blockers suite fails when one is lost or an unrecorded one appears) and 639 keep a literal (478 and 713 before the bit and byte-order models). The breakdown that follows was measured before those models and still counts their 74 methods: 490 stop at a runtime call the extractor still translates (Unsafe224,SpanandReadOnlySpan91,MemoryMarshal34,BitOperations30,Math.DivRemand similar 19,BinaryPrimitives18), 74 at value-type fields, 64 atinitobj,ldobj,stobjorsizeof, 50 atconstrained.,callvirtorldftn, and 28 atldstrorldtoken.main. Reuse of a summary across extractions with its invalidation, and binding beyond the method record (the site lemma cannot conclude the pin while the call check compares owners as text) remain. The migration of the proof corpus (Migrate checked execution and consumer proofs from CIL.Op to canonical CIL #598) waits on canonical execution.Instructionconstructors do not decode: instance, virtual and indirect calls, static fields, value-type fields, block and size instructions and runtime tokens.byteString, a string stored as its bytes behind a decided spelling, read at 27,474, 92,662 and 353,187 heartbeats at 20, 80 and 320 bytes against 103,840, 604,639 and 2,614,145 for the literal); the extractor does not emit such constants yet. On hand-edited extractions they take 13 to 22 percent off larger extractions. Lean 4.36.0 does not change this cost or the numeral collision cost (both measured on 4.35.0 and 4.36.0).The carried metadata is checked internally; its complete correspondence to pinned image bytes remains unfinished. This draft does not yet satisfy every acceptance criterion of the linked issues.
Not verified
49bd7ab3, which failed three suites on tests that the next push fixed; the latest full pass is run 44234466130 on25635859. The run on this head is in progress.mainand has not come down: the same 79 suites took 17,343 s in run 44151461181 on00560842against 9,200 s onmain(27953edb), 89% more (17,400 s on75778dc8). The largest increases arelookups(94 to 2,444 s),assemblies(289 to 2,057 s),unsafe(651 to 1,382 s),stepping(105 to 817 s),evidence(799 to 1,438 s) anddispatch(726 to 1,155 s). On75778dc8, matched by stage, tests added on this branch accounted for 5,368 s and tests on both sides that cost more for 4,521 s. Measured on two batches, the declarations that exist on both sides cost the same or less, and the added cost is the new per-method evidence, led by the body check; the string constants above address its largest part. A full run takes 60 to 66 minutes.cil_managed_callson extracted evidence after the link walk change; the heartbeat comparison on the shared tactic tests after the hole,localloc,stargandldargaarms joined the first match ofstep;Tests.StoreFactsand the loop suites after the typed exception change; the linked first pass for instance, virtual and managed calls (the stepping rows exercisecallonly).callconversion; of about 13,300 per site at 256 sites, the table-shape conjuncts take about 1,650, the walk over the zipped lists 4,050, the first link read 2,560 and the link fit 2,200.Tests/SelfAdmission.cs -- --updaterecords an empty baseline and reports success when the extractor inExtractor/binis a Debug build, in which every method is "not checked". It is not fixed on this head.HasThisof the convention byte;mainhas the same site gap (validateManagedCallWithaccepts any non-call emission at an external target). Refutations:verifycan report a counterexample about another program as a refutation of this extraction. Prefixes: a malformedno.operand beforeldfldis accepted. Layouts:LayoutsValidaccepts two rows with one identity and different offsets. Scalar flow does not track which struct a receiver is. Type identity: several checks compare a type by its spelled name, so a class and a struct of one spelling, a pointer to an identically spelled type and an imported layout found by flattened name can match the wrong layout row; a typed identity replaces the spellings in six steps, the first in progress. Tuples:ValueTuple<byte,uint>.Item2binds at offset 4 where the runtime has 0. Metadata: a coded index row over 24 bits carries into the table bits. Enums: a generic argument may be an enum over a non-integer or over another enum. Emission: a name outside the basic plane reaches Lean as two NUL characters. The closure scaling row leaves the index construction out of its measurement. Earlier notes: the statics stepping row passes without its site facts, and Lean admits a classldfldathat the extractor refuses. Fixed on this head: the failure report takes the refutation from the audit's structured result; an audit request without a booleanrefutedfield is refused; the audit refuses a repeated JSON key and an unknown comparison field; a nested struct read keeps its uninitialized bytes; a vector field binds its declared lane; a class generic owner stays out of struct layouts; a platform pair item checks its declared signature. The span,Unsafe.SizeOfand decoded-only gate changes are held back until the model entry defects are fixed.