proofs.rs

Claim #6 — Verification of utf8::Incomplete::new (with Aeneas be86ab0f1989d04944292b345b24c435be3ad10a)

utf8::Incomplete::new

impl Incomplete
pub fn new(bytes: &[u8]) -> Self

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

bytes.len() ≤ 4

Formal statement

Utf8Proofs.new_total

for allbytes : Aeneas.Std.Slice Aeneas.Std.U8
assumebounded : (↑bytes).length ≤ 4
then∃ state, utf8.Incomplete.new bytes = Aeneas.Std.Result.ok state ∧ ↑state.buffer = ↑bytes ++ List.replicate (4 - (↑bytes).length) 0#u8 ∧ ↑state.buffer_len = (↑bytes).length

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

Complete Lean proposition
∀ (bytes : Aeneas.Std.Slice.{0} Aeneas.Std.U8)
  (bounded :
    @LE.le.{0} Nat instLENat (@List.length.{0} Aeneas.Std.U8 (@Aeneas.Std.Slice.val.{0} Aeneas.Std.U8 bytes))
      (@OfNat.ofNat.{0} Nat (nat_lit 4) (instOfNatNat (nat_lit 4)))),
  @Exists.{1} utf8.Incomplete fun (state : utf8.Incomplete) =>
    And
      (@Eq.{1} (Aeneas.Std.Result.{0} utf8.Incomplete) (utf8.Incomplete.new bytes)
        (@Aeneas.Std.Result.ok.{0} utf8.Incomplete state))
      (And
        (@Eq.{1} (List.{0} Aeneas.Std.U8)
          (@Aeneas.Std.Array.val.{0} Aeneas.Std.U8
            (Aeneas.Std.Usize.ofNat (@OfNat.ofNat.{0} Nat (nat_lit 4) (instOfNatNat (nat_lit 4)))
              utf8.Incomplete._proof_1)
            (utf8.Incomplete.buffer state))
          (@HAppend.hAppend.{0, 0, 0} (List.{0} Aeneas.Std.U8) (List.{0} (Aeneas.Std.UScalar Aeneas.Std.UScalarTy.U8))
            (List.{0} Aeneas.Std.U8)
            (@instHAppendOfAppend.{0} (List.{0} Aeneas.Std.U8) (@List.instAppend.{0} Aeneas.Std.U8))
            (@Aeneas.Std.Slice.val.{0} Aeneas.Std.U8 bytes)
            (@List.replicate.{0} (Aeneas.Std.UScalar Aeneas.Std.UScalarTy.U8)
              (@HSub.hSub.{0, 0, 0} Nat Nat Nat (@instHSub.{0} Nat instSubNat)
                (@OfNat.ofNat.{0} Nat (nat_lit 4) (instOfNatNat (nat_lit 4)))
                (@List.length.{0} Aeneas.Std.U8 (@Aeneas.Std.Slice.val.{0} Aeneas.Std.U8 bytes)))
              (Aeneas.Std.U8.ofNat (@OfNat.ofNat.{0} Nat (nat_lit 0) (instOfNatNat (nat_lit 0)))
                (@of_decide_eq_true
                  (@LE.le.{0} Nat instLENat (@OfNat.ofNat.{0} Nat (nat_lit 0) (instOfNatNat (nat_lit 0)))
                    (Aeneas.Std.UScalar.cMax Aeneas.Std.UScalarTy.U8))
                  (Nat.decLe (@OfNat.ofNat.{0} Nat (nat_lit 0) (instOfNatNat (nat_lit 0)))
                    (Aeneas.Std.UScalar.cMax Aeneas.Std.UScalarTy.U8))
                  (@id.{0}
                    (@Eq.{1} Bool
                      (@Decidable.decide
                        (@LE.le.{0} Nat instLENat (@OfNat.ofNat.{0} Nat (nat_lit 0) (instOfNatNat (nat_lit 0)))
                          (Aeneas.Std.UScalar.cMax Aeneas.Std.UScalarTy.U8))
                        (Nat.decLe (@OfNat.ofNat.{0} Nat (nat_lit 0) (instOfNatNat (nat_lit 0)))
                          (Aeneas.Std.UScalar.cMax Aeneas.Std.UScalarTy.U8)))
                      Bool.true)
                    (@Eq.refl.{1} Bool Bool.true)))))))
        (@Eq.{1} Nat (@Aeneas.Std.UScalar.val Aeneas.Std.UScalarTy.U8 (utf8.Incomplete.buffer_len state))
          (@List.length.{0} Aeneas.Std.U8 (@Aeneas.Std.Slice.val.{0} Aeneas.Std.U8 bytes))))

Theorem source at recorded commit · Recorded check

Referenced definitions (up to 100 direct references)
  • Aeneas.Std.Slice · Aeneas.Std.SliceDef
  • Aeneas.Std.U8 · Aeneas.Std.Scalar.Core
  • LE.le · Init.Prelude
  • Nat · Init.Prelude
  • instLENat · Init.Prelude
  • List.length · Init.Prelude
  • Aeneas.Std.Slice.val · Aeneas.Std.SliceDef
  • OfNat.ofNat · Init.Prelude
  • instOfNatNat · Init.Prelude
  • Exists · Init.Core
  • utf8.Incomplete
  • And · Init.Prelude
  • Eq · Init.Prelude
  • Aeneas.Std.Result · Aeneas.Std.Primitives
  • utf8.Incomplete.new
  • Aeneas.Std.Result.ok · Aeneas.Std.Primitives
  • List · Init.Prelude
  • Aeneas.Std.Array.val · Aeneas.Std.Array.Array
  • Aeneas.Std.Usize.ofNat · Aeneas.Std.Scalar.Core
  • utf8.Incomplete._proof_1 · Utf8
  • utf8.Incomplete.buffer
  • HAppend.hAppend · Init.Prelude
  • Aeneas.Std.UScalar · Aeneas.Std.Scalar.Core
  • Aeneas.Std.UScalarTy.U8 · Aeneas.Std.Scalar.Core
  • instHAppendOfAppend · Init.Prelude
  • List.instAppend · Init.Data.List.Basic
  • List.replicate · Init.Data.List.Basic
  • HSub.hSub · Init.Prelude
  • instHSub · Init.Prelude
  • instSubNat · Init.Prelude
  • Aeneas.Std.U8.ofNat · Aeneas.Std.Scalar.Core
  • of_decide_eq_true · Init.Prelude
  • Aeneas.Std.UScalar.cMax · Aeneas.Std.Scalar.Core
  • Nat.decLe · Init.Prelude
  • id · Init.Prelude
  • Bool · Init.Prelude
  • Decidable.decide · Init.Prelude
  • Bool.true · Init.Prelude
  • Eq.refl · Init.Prelude
  • Aeneas.Std.UScalar.val · Aeneas.Std.Scalar.Core
  • utf8.Incomplete.buffer_len

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

Evidence

https://github.com/MasWag/crate-proofs/blob/5cf14f7365d7b282e769740ee97d156ad5f7d061/utf-8/0.7.6/aeneas/profiles/default/proofs/Proofs.lean#L27-L42

What is trusted

From the report

The selected Rust implementation is translated through Charon and Aeneas and checked by Lean. The guarantees depend on the correctness of that translation, its models of Rust operations, and the Lean kernel. The model represents referenced data by value; the clone result does not establish reference identity. The models and extraction do not by themselves establish all Rust memory-safety properties.

Technical limitations

From the report

This is partial coverage: decode, try_complete, the lossy and buffered reader consumers, formatting and error-source accessors are not covered by the selected API claims. In particular, the constructor proofs do not establish UTF-8 decoding or streaming behavior. Incomplete::new is covered only for inputs of at most four bytes. A separate experiment checks private helpers in adapted source under explicit classification premises; it does not establish a release API guarantee or a formal equivalence to release code. A complete formal correspondence proof between Rust execution and the translated model is not provided.

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 →