| -- Copyright 2026 The Fuchsia Authors. All rights reserved. | |
| -- Use of this source code is governed by a BSD-style license that can be | |
| -- found in the LICENSE file. | |
| import Assumptions | |
| import Spec | |
| import Proof | |
| import Extracted | |
| /-! | |
| # Top-Level Verified Contract for `ebpf_core` (`spec/Contract.lean`) | |
| This security-critical module (`spec/Contract.lean`, classified as High risk in | |
| `RISK.md` and governed by `../REVIEW.md`) states the top-level theorems for | |
| `//src/starnix/lib/ebpf/core`, delegates each proof body to `StarnixEbpf.Proof`, | |
| and audits the axioms of every theorem using `#print axioms`. | |
| Every theorem in this file must be preceded by a `/-- **Informal**: ... -/` | |
| docstring explaining the theorem in clear, precise English. | |
| Note on partial correctness: `verify_program_core_implies_safe_and_terminating`, | |
| `verify_program_core_implies_non_interfering`, | |
| `verify_program_core_struct_accesses_well_formed`, | |
| `cbpf_to_ebpf_core_nonempty_on_ok`, `link_instructions_preserves_length`, and | |
| `link_instructions_matches_prog` currently prove **partial correctness**: they take `= .ok (.Ok ...)` as a | |
| hypothesis rather than proving `.ok` in their conclusions (unlike the scalar, | |
| instruction-helper, `execute_core_loop1`, and | |
| `backend_simulates_program_satisfiable` theorems). In particular, the | |
| `verify_program_core` theorems establish safety, bounded termination, | |
| non-interference, and struct-access metadata well-formedness of any program | |
| accepted without error by `verify_program_core`, and do not yet prove verifier | |
| panic-freedom, arithmetic-overflow-freedom, or termination (tracked in | |
| https://fxbug.dev/589873254). | |
| -/ | |
| namespace StarnixEbpf.Contract | |
| open Aeneas.Std | |
| open StarnixEbpf.Assumptions | |
| open StarnixEbpf.Spec | |
| /-- | |
| **Informal**: Writing an 8-bit opcode into an `EbpfInstruction` with `set_code` | |
| and reading it back with `code` always succeeds and returns the exact opcode | |
| that was written. | |
| -/ | |
| theorem ebpf_instruction_set_code_roundtrip | |
| (insn : ebpf_core.api.EbpfInstruction) (opcode : U8) : | |
| ∃ insn', | |
| ebpf_core.api.EbpfInstruction.set_code insn opcode = .ok insn' ∧ | |
| ebpf_core.api.EbpfInstruction.code insn' = .ok opcode := by | |
| exact StarnixEbpf.Proof.ebpf_instruction_set_code_roundtrip insn opcode | |
| #print axioms ebpf_instruction_set_code_roundtrip | |
| /-- | |
| **Informal**: Applying big-endian byte swapping (`apply_endianness` with | |
| `to_be = true`) twice at the same data width `w` always succeeds and returns | |
| the original 64-bit value masked to width `w`. | |
| -/ | |
| theorem apply_endianness_be_involutive | |
| (w : ebpf_core.api.DataWidth) (v : U64) : | |
| ∃ v1 v2, | |
| ebpf_core.api.apply_endianness true w v = .ok v1 ∧ | |
| ebpf_core.api.apply_endianness true w v1 = .ok v2 ∧ | |
| v2.bv = v.bv &&& (DataWidth.ofCore w).valMask64 := by | |
| exact StarnixEbpf.Proof.apply_endianness_be_involutive w v | |
| #print axioms apply_endianness_be_involutive | |
| /-- | |
| **Informal**: Interval addition on 64-bit unsigned ranges (`U64Range.add_range`) | |
| is sound: for any concrete 64-bit words `x` in `r1` and `y` in `r2`, their | |
| modular 64-bit sum `x + y` lies within the resulting `U64Range`. | |
| -/ | |
| theorem u64_range_add_sound | |
| (r1 r2 : ebpf_core.scalar_value.U64Range) (x y : BitVec 64) | |
| (hx : ConcretizesRange64 r1 x) | |
| (hy : ConcretizesRange64 r2 y) : | |
| ∃ rOut, | |
| ebpf_core.scalar_value.U64Range.add_range r1 r2 = .ok rOut ∧ | |
| ConcretizesRange64 rOut (x + y) := by | |
| exact StarnixEbpf.Proof.u64_range_add_sound r1 r2 x y hx hy | |
| #print axioms u64_range_add_sound | |
| /-- | |
| **Informal**: Abstract 64-bit scalar addition (`U64ScalarValueData.add_scalar`) | |
| is sound for both single-run bounds/tnum tracking and 2-safety initialization | |
| tracking: if `(x1, x2)` concretize `d1` and `(y1, y2)` concretize `d2` while | |
| agreeing on all initialized bits, then `(x1 + y1, x2 + y2)` concretize the | |
| result of `add_scalar d1 d2` and agree on all bits marked initialized in the | |
| result. | |
| -/ | |
| theorem u64_scalar_add_sound | |
| (d1 d2 : ebpf_core.scalar_value.U64ScalarValueData) | |
| (x1 x2 y1 y2 : BitVec 64) | |
| (hx : ConcretizesScalar64Rel2 d1 x1 x2) | |
| (hy : ConcretizesScalar64Rel2 d2 y1 y2) : | |
| ∃ dOut, | |
| ebpf_core.scalar_value.U64ScalarValueData.add_scalar d1 d2 = .ok dOut ∧ | |
| ConcretizesScalar64Rel2 dOut (x1 + y1) (x2 + y2) := by | |
| exact StarnixEbpf.Proof.u64_scalar_add_sound d1 d2 x1 x2 y1 y2 hx hy | |
| #print axioms u64_scalar_add_sound | |
| /-- | |
| **Informal**: Abstract 64-bit bitwise AND (`U64ScalarValueData.bitand_scalar`) | |
| is sound for both single-run bounds/tnum tracking and 2-safety initialization | |
| tracking, including zero-masking of uninitialized bits when ANDed with a known | |
| zero bit. | |
| -/ | |
| theorem u64_scalar_bitand_sound | |
| (d1 d2 : ebpf_core.scalar_value.U64ScalarValueData) | |
| (x1 x2 y1 y2 : BitVec 64) | |
| (hx : ConcretizesScalar64Rel2 d1 x1 x2) | |
| (hy : ConcretizesScalar64Rel2 d2 y1 y2) : | |
| ∃ dOut, | |
| ebpf_core.scalar_value.U64ScalarValueData.bitand_scalar d1 d2 = .ok dOut ∧ | |
| ConcretizesScalar64Rel2 dOut (x1 &&& y1) (x2 &&& y2) := by | |
| exact StarnixEbpf.Proof.u64_scalar_bitand_sound d1 d2 x1 x2 y1 y2 hx hy | |
| #print axioms u64_scalar_bitand_sound | |
| /-- | |
| **Informal**: Classic BPF (cBPF) to eBPF translation (`cbpf_to_ebpf_core`) | |
| never produces an empty eBPF program: whenever `cbpf_to_ebpf_core` returns | |
| `Ok(ebpf_code)`, the resulting instruction vector has at least one instruction. | |
| -/ | |
| theorem cbpf_to_ebpf_core_nonempty_on_ok | |
| (bpf_code : Slice ebpf_core.api.SockFilter) | |
| (config : ebpf_core.converter.CbpfConfig) | |
| (ebpf_code : alloc.vec.Vec ebpf_core.api.EbpfInstruction) | |
| (h_ok : ebpf_core.converter.cbpf_to_ebpf_core bpf_code config = | |
| .ok (.Ok ebpf_code)) : | |
| 0 < ebpf_code.val.length := by | |
| exact StarnixEbpf.Proof.cbpf_to_ebpf_core_nonempty_on_ok bpf_code config ebpf_code h_ok | |
| #print axioms cbpf_to_ebpf_core_nonempty_on_ok | |
| /-- | |
| **Informal**: Single-Execution Safety & Termination of `verify_program_core` | |
| (partial correctness): under a valid logger (`ValidVerifierLogger`) and | |
| conforming entry states (`EntryStatesConform`), whenever `verify_program_core` | |
| terminates without panicking or overflowing integer arithmetic and accepts | |
| `rawCode` under calling context `cctx` (`= .ok (.Ok verified, logger')`), | |
| `verified.code` decodes to a well-formed `Program` `prog` of the same length | |
| and executing `prog` from any conforming initial machine state (for any valid | |
| host layout and arbitrary initial uninitialized stack/register bits) terminates | |
| in at most `VERIFIER_MAX_STEPS` (`655,361`) steps without triggering any | |
| `SafetyViolation` (no out-of-bounds or misaligned stack/memory/packet accesses, | |
| no uninitialized stack reads, no invalid register accesses or writes to `r10`, | |
| no helper contract violations, and zero leaked resources on exit). | |
| **Partial-correctness scope**: Because `h_verif` is conditional on | |
| `verify_program_core ... = .ok (.Ok verified, logger')`, this theorem proves | |
| partial correctness (`= .ok (.Ok verified, logger') → ...`) and does not yet | |
| prove verifier panic-freedom, arithmetic-overflow-freedom, or termination. In | |
| Aeneas, unchecked Rust `+`/`-`/`*` operations fail with | |
| `Result.fail .arithmeticOverflow`, whereas Fuchsia release builds | |
| (`-Cdebug-assertions=no`) wrap without panicking; until totality is proved, a | |
| wrapping overflow inside `verify_program_core` could return `Ok(verified)` at | |
| runtime while leaving `h_verif : ... = .ok (.Ok verified, logger')` vacuously | |
| false. Proving totality of `verify_program_core` is tracked in | |
| https://fxbug.dev/589873254. | |
| -/ | |
| theorem verify_program_core_implies_safe_and_terminating | |
| {L : Type} (loggerInst : ebpf_core.verifier.CoreVerifierLogger L) | |
| (rawCode : alloc.vec.Vec ebpf_core.api.EbpfInstruction) | |
| (cctx : ebpf_core.verifier.CoreCallingContext) | |
| (logger logger' : L) | |
| (verified : ebpf_core.verifier.VerifiedEbpfProgram) | |
| (env : ExecEnv) | |
| (mkInit : HostLayout → SecretInit → MachineState) | |
| (h_logger : ValidVerifierLogger loggerInst) | |
| (h_entry : EntryStatesConform cctx env mkInit) | |
| (h_verif : ebpf_core.verifier.verify_program_core loggerInst rawCode cctx logger = | |
| .ok (.Ok verified, logger')) : | |
| ∃ prog, | |
| decodeVerifiedCode verified.code.val = some prog ∧ | |
| prog.size = verified.code.val.length ∧ | |
| SafeAndTerminating prog env VERIFIER_MAX_STEPS mkInit := by | |
| exact StarnixEbpf.Proof.verify_program_core_implies_safe_and_terminating | |
| loggerInst rawCode cctx logger logger' verified env mkInit h_logger h_entry h_verif | |
| #print axioms verify_program_core_implies_safe_and_terminating | |
| /-- | |
| **Informal**: Relational 2-Safety Non-Interference of `verify_program_core` | |
| (partial correctness): under a valid logger (`ValidVerifierLogger`), conforming | |
| entry states (`EntryStatesConform`), and pointer leaks disabled | |
| (`cctx.allow_ptr_leaks = false`), whenever `verify_program_core` terminates | |
| without panicking or overflowing integer arithmetic and accepts `rawCode` under | |
| calling context `cctx` (`= .ok (.Ok verified, logger')`), `verified.code` | |
| decodes to a well-formed `Program` `prog` of the same length, and for any two | |
| valid host pointer layouts `layout₁, layout₂` and any two initial uninitialized | |
| stack/register bit assignments `secret₁, secret₂`, both executions terminate in | |
| at most `VERIFIER_MAX_STEPS` (`655,361`) steps without safety violations, leave | |
| zero leaked resources on exit, and produce the exact same scalar return value | |
| and observable world state. Neither KASLR pointer values nor uninitialized host | |
| stack/register bits can leak. | |
| **Partial-correctness scope**: Because `h_verif` is conditional on | |
| `verify_program_core ... = .ok (.Ok verified, logger')`, this theorem proves | |
| partial correctness (`= .ok (.Ok verified, logger') → ...`) and does not yet | |
| prove verifier panic-freedom, arithmetic-overflow-freedom, or termination. In | |
| Aeneas, unchecked Rust `+`/`-`/`*` operations fail with | |
| `Result.fail .arithmeticOverflow`, whereas Fuchsia release builds | |
| (`-Cdebug-assertions=no`) wrap without panicking; until totality is proved, a | |
| wrapping overflow inside `verify_program_core` could return `Ok(verified)` at | |
| runtime while leaving `h_verif : ... = .ok (.Ok verified, logger')` vacuously | |
| false. Proving totality of `verify_program_core` is tracked in | |
| https://fxbug.dev/589873254. | |
| -/ | |
| theorem verify_program_core_implies_non_interfering | |
| {L : Type} (loggerInst : ebpf_core.verifier.CoreVerifierLogger L) | |
| (rawCode : alloc.vec.Vec ebpf_core.api.EbpfInstruction) | |
| (cctx : ebpf_core.verifier.CoreCallingContext) | |
| (logger logger' : L) | |
| (verified : ebpf_core.verifier.VerifiedEbpfProgram) | |
| (env : ExecEnv) | |
| (mkInit : HostLayout → SecretInit → MachineState) | |
| (h_logger : ValidVerifierLogger loggerInst) | |
| (h_entry : EntryStatesConform cctx env mkInit) | |
| (h_no_ptr_leaks : cctx.allow_ptr_leaks = false) | |
| (h_verif : ebpf_core.verifier.verify_program_core loggerInst rawCode cctx logger = | |
| .ok (.Ok verified, logger')) : | |
| ∃ prog, | |
| decodeVerifiedCode verified.code.val = some prog ∧ | |
| prog.size = verified.code.val.length ∧ | |
| NonInterfering prog env VERIFIER_MAX_STEPS mkInit := by | |
| exact StarnixEbpf.Proof.verify_program_core_implies_non_interfering | |
| loggerInst rawCode cctx logger logger' verified env mkInit | |
| h_logger h_entry h_no_ptr_leaks h_verif | |
| #print axioms verify_program_core_implies_non_interfering | |
| /-- | |
| **Informal**: Struct-Access Metadata Well-Formedness of `verify_program_core` | |
| (partial correctness): whenever `verify_program_core` terminates without | |
| panicking or overflowing integer arithmetic and accepts `rawCode` under calling | |
| context `cctx` (`= .ok (.Ok verified, logger')`), `verified.code` decodes to a | |
| `Program` `prog` such that `verified.struct_access_instructions` satisfies | |
| `StructAccessesWellFormed` relative to `prog` (pairwise distinct PCs, each | |
| pointing to an in-bounds `.load` with width `.u32` whenever | |
| `is_32_bit_ptr_load = true` or a `.store` with `is_32_bit_ptr_load = false`). | |
| **Partial-correctness scope**: Same as | |
| `verify_program_core_implies_safe_and_terminating` (tracked in | |
| https://fxbug.dev/589873254). | |
| -/ | |
| theorem verify_program_core_struct_accesses_well_formed | |
| {L : Type} (loggerInst : ebpf_core.verifier.CoreVerifierLogger L) | |
| (rawCode : alloc.vec.Vec ebpf_core.api.EbpfInstruction) | |
| (cctx : ebpf_core.verifier.CoreCallingContext) | |
| (logger logger' : L) | |
| (verified : ebpf_core.verifier.VerifiedEbpfProgram) | |
| (h_verif : ebpf_core.verifier.verify_program_core loggerInst rawCode cctx logger = | |
| .ok (.Ok verified, logger')) : | |
| ∃ prog, | |
| decodeVerifiedCode verified.code.val = some prog ∧ | |
| StructAccessesWellFormed verified.struct_access_instructions.val prog := by | |
| exact StarnixEbpf.Proof.verify_program_core_struct_accesses_well_formed | |
| loggerInst rawCode cctx logger logger' verified h_verif | |
| #print axioms verify_program_core_struct_accesses_well_formed | |
| /-- | |
| **Informal**: Bytecode linking (`link_instructions`) preserves the instruction | |
| stream length of a `VerifiedEbpfProgram` whenever linking succeeds. | |
| -/ | |
| theorem link_instructions_preserves_length | |
| (verified : ebpf_core.verifier.VerifiedEbpfProgram) | |
| (linkage : ebpf_core.program.ProgramLinkageInfo) | |
| (linkedCode : alloc.vec.Vec ebpf_core.api.EbpfInstruction) | |
| (h_link : ebpf_core.program.link_instructions verified linkage = | |
| .ok (.Ok linkedCode)) : | |
| linkedCode.val.length = verified.code.val.length := by | |
| exact StarnixEbpf.Proof.link_instructions_preserves_length verified linkage linkedCode h_link | |
| #print axioms link_instructions_preserves_length | |
| /-- | |
| **Informal**: Bytecode-linking correspondence (`link_instructions_matches_prog`, | |
| partial correctness): whenever `verified.code` decodes to `prog`, | |
| `verified.struct_access_instructions` satisfies `StructAccessesWellFormed` | |
| relative to `prog` (discharged for verified programs by | |
| `verify_program_core_struct_accesses_well_formed`), `linkage` conforms to host | |
| address layout `layout` (`LinkageConformsLayout`), and `link_instructions` | |
| succeeds with `linkedCode`, the resulting raw instruction stream satisfies | |
| `LinkedCodeMatchesProg linkedCode.val prog layout verified.struct_access_instructions.val linkage.struct_mappings.val`: | |
| it decodes to an equal-length `Program` in which every `lddwMap` and | |
| `lddwMapValue` pseudo-load is rewritten to a concrete `src = 0` `lddwImm` | |
| carrying `layout.mapAddr` / `layout.mapDataAddr + off`, only struct | |
| loads/stores listed in `verified.struct_access_instructions` reflect the exact | |
| `linkage.struct_mappings` offset and 32-bit-to-64-bit width rewrites, and all | |
| other instructions (including non-struct loads and stores) are unchanged. | |
| -/ | |
| theorem link_instructions_matches_prog | |
| (verified : ebpf_core.verifier.VerifiedEbpfProgram) | |
| (linkage : ebpf_core.program.ProgramLinkageInfo) | |
| (linkedCode : alloc.vec.Vec ebpf_core.api.EbpfInstruction) | |
| (prog : Program) (layout : HostLayout) | |
| (h_dec : decodeVerifiedCode verified.code.val = some prog) | |
| (h_layout : LinkageConformsLayout linkage layout) | |
| (h_sa : StructAccessesWellFormed verified.struct_access_instructions.val prog) | |
| (h_link : ebpf_core.program.link_instructions verified linkage = | |
| .ok (.Ok linkedCode)) : | |
| LinkedCodeMatchesProg linkedCode.val prog layout | |
| verified.struct_access_instructions.val linkage.struct_mappings.val := by | |
| exact StarnixEbpf.Proof.link_instructions_matches_prog | |
| verified linkage linkedCode prog layout h_dec h_layout h_sa h_link | |
| #print axioms link_instructions_matches_prog | |
| /-- | |
| **Informal**: Interpreter simulation (`execute_core_simulates_run_steps`): for | |
| any host `EbpfMachineBackend` that refines single-step transitions | |
| (`BackendSimulatesProgram`, including `LinkedCodeMatchesProg` for `code`, | |
| `structAccesses`, and `structMappings` and `secret.preserveCallScratch = true`), | |
| whenever the reference semantics `runSteps` halts with return value `ret`, the | |
| extracted Rust interpreter loop `execute_core_loop1` terminates without runtime | |
| error and returns `Ok(ret)`. | |
| -/ | |
| theorem execute_core_simulates_run_steps | |
| {B : Type} (inst : ebpf_core.executor.EbpfMachineBackend B) | |
| (code : Slice ebpf_core.api.EbpfInstruction) | |
| (prog : Program) (env : ExecEnv) (layout : HostLayout) (secret : SecretInit) | |
| (structAccesses : List ebpf_core.verifier.StructAccess) | |
| (structMappings : List ebpf_core.program.StructFieldMapping) | |
| (R : B → MachineState → Prop) | |
| (fuel : Nat) (b : B) (st : MachineState) | |
| (istate : ebpf_core.executor.InterpreterState) | |
| (ret : BitVec 64) (finalWorld : WorldState) | |
| (h_sim : BackendSimulatesProgram inst code prog env layout secret structAccesses structMappings R) | |
| (h_rel : R b st) | |
| (h_res : istate.result = none) | |
| (h_pc : istate.pc.val = st.pc) | |
| (h_regs : InterpreterRegsMatch layout st istate.registers) | |
| (h_run : runSteps prog env layout secret fuel st = some (.inl (ret, finalWorld))) : | |
| ∃ bFinal, | |
| ebpf_core.executor.execute_core_loop1 inst code b istate = | |
| .ok (.Ok ⟨ret⟩, bFinal) := by | |
| exact StarnixEbpf.Proof.execute_core_simulates_run_steps | |
| inst code prog env layout secret structAccesses structMappings R fuel b st istate ret finalWorld | |
| h_sim h_rel h_res h_pc h_regs h_run | |
| #print axioms execute_core_simulates_run_steps | |
| /-- | |
| **Informal**: The simulation contract `BackendSimulatesProgram` and the | |
| top-level `execute_core_simulates_run_steps` hypothesis bundle are jointly | |
| satisfiable by a concrete, non-trivial witness. Specifically, there exist a | |
| concrete backend `B` with an `EbpfMachineBackend B` instance, a concrete | |
| `VerifiedEbpfProgram` record `verified` and `ProgramLinkageInfo` record | |
| `linkage`, a linked instruction vector `linkedCode`, a decoded abstract | |
| program `prog`, an execution environment `env`, a host layout `layout`, a | |
| secret initializer `secret`, a simulation relation `R`, an initial backend | |
| state `b0`, a pre-populated abstract `MachineState` `st0`, an initial | |
| `InterpreterState` `istate0`, an array buffer identifier `arrId`, a step | |
| budget `fuel`, and a final world `finalWorld` (this witness constructs | |
| `verified` and `st0` directly rather than invoking `verify_program_core` or | |
| `EntryStatesConform`) such that: | |
| 1. `ValidHostLayout layout`, `LinkageConformsLayout linkage layout`, | |
| `StructAccessesWellFormed verified.struct_access_instructions.val prog`, | |
| `decodeVerifiedCode verified.code.val = some prog`, and | |
| `link_instructions verified linkage = .ok (.Ok linkedCode)` all hold; | |
| 2. `prog` is straight-line (containing no `.jump` or `.condJump` instructions | |
| and placing `.exit` only at `prog.size - 1`) and contains a map-fd | |
| `lddwMap` instruction, two distinct map-value `lddwMapValue` instructions | |
| targeting the same map and offset, an external helper call | |
| `callExternal hIdx` whose `env.helpers hIdx` spec has void | |
| (uninitialized `.scalar false`) return and `invalidateArrayBounds = true`, | |
| and a legacy packet load `loadPacket`; | |
| 3. in `st0`, `st0.pc = 0`, `st0.world.arrayEpoch arrId = 0`, register `r0` | |
| starts at a non-zero scalar value, register `r7` holds | |
| `.endArrayPtr arrId 0`, and `layout.arrayBase arrId 0` differs from | |
| `layout.arrayBase arrId 1`; | |
| 4. `BackendSimulatesProgram` holds for `(inst, linkedCode.deref, prog, env, | |
| layout, secret, verified.struct_access_instructions.val, | |
| linkage.struct_mappings.val, R)`, with `R b0 st0`, `istate0.result = none`, | |
| `istate0.pc.val = st0.pc`, and `InterpreterRegsMatch layout st0 | |
| istate0.registers`; and | |
| 5. abstract `runSteps` terminates cleanly in `fuel` steps with scalar exit value | |
| `142#64` and `finalWorld` satisfying `finalWorld.arrayEpoch arrId = 1`, | |
| `finalWorld.arrayLen arrId 1 < finalWorld.arrayLen arrId 0`, and | |
| `readBufWord st0.world.bufBytes (.mapValue 0) 0#64 .u64 ≠ | |
| readBufWord finalWorld.bufBytes (.mapValue 0) 0#64 .u64`, while concrete | |
| `execute_core_loop1` terminates with `.ok (.Ok 142#u64, bFinal)`. | |
| -/ | |
| theorem backend_simulates_program_satisfiable : | |
| ∃ (B : Type) (inst : ebpf_core.executor.EbpfMachineBackend B) | |
| (verified : ebpf_core.verifier.VerifiedEbpfProgram) | |
| (linkage : ebpf_core.program.ProgramLinkageInfo) | |
| (linkedCode : alloc.vec.Vec ebpf_core.api.EbpfInstruction) | |
| (prog : Program) (env : ExecEnv) (layout : HostLayout) (secret : SecretInit) | |
| (R : B → MachineState → Prop) (b0 : B) (st0 : MachineState) | |
| (istate0 : ebpf_core.executor.InterpreterState) | |
| (arrId : MemoryId) (fuel : Nat) (finalWorld : WorldState), | |
| ValidHostLayout layout ∧ | |
| LinkageConformsLayout linkage layout ∧ | |
| StructAccessesWellFormed verified.struct_access_instructions.val prog ∧ | |
| decodeVerifiedCode verified.code.val = some prog ∧ | |
| ebpf_core.program.link_instructions verified linkage = .ok (.Ok linkedCode) ∧ | |
| (∃ d, Insn.lddwMap d 0 ∈ prog.toList) ∧ | |
| (∃ d₁ d₂, d₁ ≠ d₂ ∧ | |
| Insn.lddwMapValue d₁ 0 0#64 ∈ prog.toList ∧ | |
| Insn.lddwMapValue d₂ 0 0#64 ∈ prog.toList) ∧ | |
| (∃ hIdx hSpec, | |
| Insn.callExternal hIdx ∈ prog.toList ∧ | |
| env.helpers hIdx = some hSpec ∧ | |
| hSpec.ret = .scalar false ∧ | |
| hSpec.invalidateArrayBounds = true) ∧ | |
| (∃ w off ind, Insn.loadPacket w off ind ∈ prog.toList) ∧ | |
| (∃ v, v ≠ 0#64 ∧ st0.regs 0 = .scalar v) ∧ | |
| st0.pc = 0 ∧ | |
| st0.regs 7 = .endArrayPtr arrId 0 ∧ | |
| st0.world.arrayEpoch arrId = 0 ∧ | |
| layout.arrayBase arrId 0 ≠ layout.arrayBase arrId 1 ∧ | |
| (∀ (k : Nat) (hk : k < prog.size), | |
| match prog[k]'hk with | |
| | .jump _ | .condJump _ _ _ _ _ => False | |
| | .exit => k = prog.size - 1 | |
| | _ => True) ∧ | |
| BackendSimulatesProgram inst (alloc.vec.Vec.deref linkedCode) prog env layout secret | |
| verified.struct_access_instructions.val linkage.struct_mappings.val R ∧ | |
| R b0 st0 ∧ | |
| istate0.result = none ∧ | |
| istate0.pc.val = st0.pc ∧ | |
| InterpreterRegsMatch layout st0 istate0.registers ∧ | |
| runSteps prog env layout secret fuel st0 = some (.inl (142#64, finalWorld)) ∧ | |
| finalWorld.arrayEpoch arrId = 1 ∧ | |
| finalWorld.arrayLen arrId 1 < finalWorld.arrayLen arrId 0 ∧ | |
| readBufWord st0.world.bufBytes (.mapValue 0) 0#64 .u64 ≠ | |
| readBufWord finalWorld.bufBytes (.mapValue 0) 0#64 .u64 ∧ | |
| ∃ bFinal, | |
| ebpf_core.executor.execute_core_loop1 inst (alloc.vec.Vec.deref linkedCode) b0 istate0 = | |
| .ok (.Ok 142#u64, bFinal) := | |
| StarnixEbpf.Proof.backend_simulates_program_satisfiable | |
| #print axioms backend_simulates_program_satisfiable | |
| end StarnixEbpf.Contract |