proofs.rs

Claim #36 — Verification of leb128fmt::encode_fixed_uint_slice (with Aeneas be86ab0f1989d04944292b345b24c435be3ad10a)

leb128fmt::encode_fixed_uint_slice

pub fn encode_fixed_uint_slice<T, const BITS: u32>(value: T, output: &mut [u8], pos: &mut usize) -> Option<usize> where T: Copy + core::ops::BitAnd + core::ops::Shr<u32> + core::ops::ShrAssign<u32> + From<u8> + UInt, <T as core::ops::Shr<u32>>::Output: PartialEq<T>, u8: TryFrom<<T as core::ops::BitAnd>::Output>

Tool: Aeneas be86ab0f1989d04944292b345b24c435be3ad10a

This claim has no explanation of its own. Read the report Overview, and treat the formal statement below as authoritative. See Concepts and terminology.

Preconditions

T = u16 and 1 <= BITS <= 16 and initial cursor <= buffer length

Formal statement

leb128fmt.writerProof.u16_fixed_spec

for allwidth : Aeneas.Std.U32
for allvalue : Aeneas.Std.U16
for allbefore : Aeneas.Std.Slice Aeneas.Std.U8
for allstart : Aeneas.Std.Usize
assumehstart : ↑start ≤ (↑before).length
assumehwidth : ↑width ≤ 16
assumehpositive : 0 < ↑width
then∃ out, leb128fmt_writer_model.u16_fixed width value before start = Aeneas.Std.Result.ok out ∧ leb128fmt.sliceProof.UIntFixedWriterPost (↑width) (↑value) before start out

In Lean notation, ↑ denotes an implicit type conversion (coercion).

Complete Lean proposition
∀ (width : Aeneas.Std.U32) (value : Aeneas.Std.U16) (before : Aeneas.Std.Slice.{0} Aeneas.Std.U8)
  (start : Aeneas.Std.Usize)
  (hstart :
    @LE.le.{0} Nat instLENat (@Aeneas.Std.UScalar.val Aeneas.Std.UScalarTy.Usize start)
      (@List.length.{0} Aeneas.Std.U8 (@Aeneas.Std.Slice.val.{0} Aeneas.Std.U8 before)))
  (hwidth :
    @LE.le.{0} Nat instLENat (@Aeneas.Std.UScalar.val Aeneas.Std.UScalarTy.U32 width)
      (@OfNat.ofNat.{0} Nat (nat_lit 16) (instOfNatNat (nat_lit 16))))
  (hpositive :
    @LT.lt.{0} Nat instLTNat (@OfNat.ofNat.{0} Nat (nat_lit 0) (instOfNatNat (nat_lit 0)))
      (@Aeneas.Std.UScalar.val Aeneas.Std.UScalarTy.U32 width)),
  @Exists.{1}
    (Prod.{0, 0} (Option.{0} Aeneas.Std.Usize) (Prod.{0, 0} (Aeneas.Std.Slice.{0} Aeneas.Std.U8) Aeneas.Std.Usize))
    fun
      (out :
        Prod.{0, 0} (Option.{0} Aeneas.Std.Usize)
          (Prod.{0, 0} (Aeneas.Std.Slice.{0} Aeneas.Std.U8) Aeneas.Std.Usize)) =>
    And
      (@Eq.{1}
        (Aeneas.Std.Result.{0}
          (Prod.{0, 0} (Option.{0} Aeneas.Std.Usize)
            (Prod.{0, 0} (Aeneas.Std.Slice.{0} Aeneas.Std.U8) Aeneas.Std.Usize)))
        (leb128fmt_writer_model.u16_fixed width value before start)
        (@Aeneas.Std.Result.ok.{0}
          (Prod.{0, 0} (Option.{0} Aeneas.Std.Usize)
            (Prod.{0, 0} (Aeneas.Std.Slice.{0} Aeneas.Std.U8) Aeneas.Std.Usize))
          out))
      (leb128fmt.sliceProof.UIntFixedWriterPost (@Aeneas.Std.UScalar.val Aeneas.Std.UScalarTy.U32 width)
        (@Aeneas.Std.UScalar.val Aeneas.Std.UScalarTy.U16 value) before start out)

Theorem source at recorded commit · Recorded check

Referenced definitions (up to 100 direct references)
  • Aeneas.Std.U32 · Aeneas.Std.Scalar.Core
  • Aeneas.Std.U16 · Aeneas.Std.Scalar.Core
  • Aeneas.Std.Slice · Aeneas.Std.SliceDef
  • Aeneas.Std.U8 · Aeneas.Std.Scalar.Core
  • Aeneas.Std.Usize · Aeneas.Std.Scalar.Core
  • LE.le · Init.Prelude
  • Nat · Init.Prelude
  • instLENat · Init.Prelude
  • Aeneas.Std.UScalar.val · Aeneas.Std.Scalar.Core
  • Aeneas.Std.UScalarTy.Usize · Aeneas.Std.Scalar.Core
  • List.length · Init.Prelude
  • Aeneas.Std.Slice.val · Aeneas.Std.SliceDef
  • Aeneas.Std.UScalarTy.U32 · Aeneas.Std.Scalar.Core
  • OfNat.ofNat · Init.Prelude
  • instOfNatNat · Init.Prelude
  • LT.lt · Init.Prelude
  • instLTNat · Init.Prelude
  • Exists · Init.Core
  • Prod · Init.Prelude
  • Option · Init.Prelude
  • And · Init.Prelude
  • Eq · Init.Prelude
  • Aeneas.Std.Result · Aeneas.Std.Primitives
  • leb128fmt_writer_model.u16_fixed
  • Aeneas.Std.Result.ok · Aeneas.Std.Primitives
  • leb128fmt.sliceProof.UIntFixedWriterPost
  • Aeneas.Std.UScalarTy.U16 · Aeneas.Std.Scalar.Core

Mapping: manual. Translation was not rerun by this recording.

Evidence

https://github.com/MasWag/crate-proofs/blob/bb7e96e52ff285bca94443d090899706c2f127ec/leb128fmt/0.1.0/aeneas/profiles/default/proofs/ProofsConcreteUnsignedWriters.lean#L122-L127

What is trusted

From the report

The concrete writer proofs use a local adapter for the extracted primitive conversions. It erases the generated conversion error payload to the pinned backend’s unit error model; the proofs establish that narrowing the masked payload succeeds and preserves its value, so that error payload is not observed in the proved paths. The adapter also forwards the fixed writer’s length helper to a separately extracted release body. This connection relies on the extracted operations and their correspondence to Rust. The results depend on the correspondence of the pinned Rust-to-Lean translation and Aeneas models for integer arithmetic, shifts, indexing and arrays to the Rust operations, and on Lean's kernel. They do not independently establish that correspondence.

Technical limitations

From the report

The slice claims are restricted to the types, widths and cursor conditions stated above. The unsigned small-width decoder claim describes the implementation's actual behavior, including modeled failure, rather than the intended field-range contract. The actual decoder behavior at multiples of seven is broader than the intended field limit, as the findings illustrate. Parameterized array macro expansions at other widths, error formatting and the full dynamic return signatures of the standard error source and deprecated cause methods remain outside the proved scope. The observers establish only whether those methods return None. The service catalogue does not expose the five locally proved inherited methods clone_from, ne, assert_receiver_is_total_eq, description, and cause; they therefore have no published API claim in this report. Native observations in verification/findings/ are separate from the formal results.

Tool limitations

Lean backend only, requiring cargo-proofs 0.4.0 or later. The version identifies the official Aeneas Git revision pinned in lake-manifest.json (backends/lean); this revision uses Lean 4.35.0. The recorder checks committed Lean theorem declarations and permits only propext, Classical.choice, and Quot.sound as transitive axioms. It rejects sorryAx and custom axioms, including axiomatized external models. Charon/Aeneas extraction is not rerun. The author must review that the committed functional model matches the recorded Rust source, that the named theorem corresponds to the public API, and that the reported precondition matches the theorem. A checked theorem alone does not establish those links or the adequacy of the specification. The current adapter records the default Cargo configuration, with ordinary Lean module paths and a pinned official Git dependency. Other backends, custom Lake source directories, and local-path Aeneas dependencies are unsupported. See https://proofs.rs/book/aeneas.html and https://github.com/AeneasVerif/aeneas/tree/be86ab0f1989d04944292b345b24c435be3ad10a.

Updated 2026-10-16 00:00 UTC

Aeneas be86ab0f1989d04944292b345b24c435be3ad10a — version details

Read and join the discussion on the report →