Claim #3 — Verification of cesu8::is_valid_cesu8 (with creusot 0.14.0)
Tool: creusot 0.14.0
Preconditions
true
Creusot specification
#[ensures(result == compatible_bytes(text@.to_bytes(), false))]
pub fn is_valid_cesu8(text: &str) -> boolEvidence
What is trusted
From the report
The checks depend on Creusot's Rust and standard-library models and on the translation and provers. A local external contract assumes that str::as_bytes returns the concatenation of the ordinary UTF-8 encodings of the string's scalars. In particular, the whole-input UTF-8 validator is assumed to preserve the bytes on success and, on error, exclude every scalar sequence whose ordinary UTF-8 encoding equals the input; the conventional UTF-8 encoding of each scalar and injectivity of string encoding are also model assumptions. Slice, iterator, vector and Cow operations use their standard-library contracts. The fallback proves that its resulting bytes represent valid UTF-8 before the modeled unchecked string construction. The CESU-8 encoder and parser and their relation are checked, rather than assumed.
Technical limitations
From the report
The checked source is a verification copy adapted from the 1.1.0 release. Its encoder reconstructs a supplementary scalar from four UTF-8 bytes instead of calling .chars().next() on an unchecked four-byte string slice; compatibility scans are indexed, the width table is constant, and decoder token operations are factored into helpers. These changes address verification model limitations while retaining the decoder's whole-input dispatch and surrogate bit operations. A checked arithmetic lemma relates the capacity expressions on the modeled length domain. Separate finite native tests compare the copy with the release, including all byte strings of length at most two; an independent encoding oracle checks individual Unicode scalar encodings. They do not prove equivalence for all inputs: formal equivalence of the adapted copy to the published release remains unproved.
The functional contracts observe byte and scalar contents and Cow variants, not pointer identity, allocation behavior or allocator failure. They do not establish unconditional termination or whole-crate memory safety. Error formatting and diagnostic traits are outside the six selected public contracts.